From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Markus Triska Newsgroups: gmane.emacs.devel Subject: Re: display-completion-list should not strip text properties Date: Wed, 11 Apr 2007 18:38:31 +0200 Message-ID: <87hcrmg92w.fsf@gmx.at> References: <878xd8dw3d.fsf@stupidchicken.com> <17941.35328.281122.300772@farnswood.snap.net.nz> <5y7isq2tho.fsf@fencepost.gnu.org> <87d52ifekm.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1176309535 22713 80.91.229.12 (11 Apr 2007 16:38:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 11 Apr 2007 16:38:55 +0000 (UTC) Cc: Glenn Morris , Nick Roberts , rms@gnu.org, emacs-devel@gnu.org To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 11 18:38:51 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HbfqM-0003q3-J7 for ged-emacs-devel@m.gmane.org; Wed, 11 Apr 2007 18:38:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HbfuQ-0005aq-A6 for ged-emacs-devel@m.gmane.org; Wed, 11 Apr 2007 12:43:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HbfuM-0005Wm-Iv for emacs-devel@gnu.org; Wed, 11 Apr 2007 12:42:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HbfuK-0005TL-Sq for emacs-devel@gnu.org; Wed, 11 Apr 2007 12:42:58 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HbfuK-0005T0-Px for emacs-devel@gnu.org; Wed, 11 Apr 2007 12:42:56 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1HbfqF-0001LY-Fl for emacs-devel@gnu.org; Wed, 11 Apr 2007 12:38:43 -0400 Original-Received: (qmail invoked by alias); 11 Apr 2007 16:38:42 -0000 Original-Received: from chello062178240212.3.14.tuwien.teleweb.at (EHLO enterprise) [62.178.240.212] by mail.gmx.net (mp034) with SMTP; 11 Apr 2007 18:38:42 +0200 X-Authenticated: #4064391 X-Provags-ID: V01U2FsdGVkX19r8DhumQdr7ECmYsr/f5chrR8baK1Kstx7HnUgHg D34s+ES2Al37HV X-Y-GMX-Trusted: 0 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:69292 Archived-At: Chong Yidong writes: > 1997-11-02 emacs-lisp/byte-opt.el (byte-optimize-concat): New function. > Revertable. (It's an optional optimization.) This had evolved into a more general and worthwhile optimisation for several pure functions. Here's an independent implementation: 2007-04-11 Markus Triska * emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): evaluate pure function calls if possible (byte-optimize-all-constp): new function Index: byte-opt.el =================================================================== RCS file: /sources/emacs/emacs/lisp/emacs-lisp/byte-opt.el,v retrieving revision 1.93 diff -c -r1.93 byte-opt.el *** byte-opt.el 11 Apr 2007 03:57:11 -0000 1.93 --- byte-opt.el 11 Apr 2007 15:43:41 -0000 *************** *** 557,564 **** ;; Otherwise, no args can be considered to be for-effect, ;; even if the called function is for-effect, because we ;; don't know anything about that function. ! (cons fn (mapcar 'byte-optimize-form (cdr form))))))) ! (defun byte-optimize-form (form &optional for-effect) "The source-level pass of the optimizer." --- 557,576 ---- ;; Otherwise, no args can be considered to be for-effect, ;; even if the called function is for-effect, because we ;; don't know anything about that function. ! (let ((args (mapcar #'byte-optimize-form (cdr form)))) ! (if (and (get fn 'pure) ! (byte-optimize-all-constp args)) ! (list 'quote (apply fn (mapcar #'eval args))) ! (cons fn args))))))) ! ! (defun byte-optimize-all-constp (list) ! "Non-nil iff all elements of LIST satisfy `byte-compile-constp'." ! (let ((constant t)) ! (while (and list constant) ! (unless (byte-compile-constp (car list)) ! (setq constant nil)) ! (setq list (cdr list))) ! constant)) (defun byte-optimize-form (form &optional for-effect) "The source-level pass of the optimizer." *************** *** 1241,1246 **** --- 1253,1270 ---- (setq side-effect-and-error-free-fns (cdr side-effect-and-error-free-fns))) nil) + + ;; pure functions are side-effect free functions whose values depend + ;; only on their arguments. For these functions, calls with constant + ;; arguments can be evaluated at compile time. This may shift run time + ;; errors to compile time. + + (let ((pure-fns + '(concat symbol-name regexp-opt regexp-quote string-to-syntax))) + (while pure-fns + (put (car pure-fns) 'pure t) + (setq pure-fns (cdr pure-fns))) + nil) (defun byte-compile-splice-in-already-compiled-code (form) ;; form is (byte-code "..." [...] n)