From: Markus Triska <markus.triska@gmx.at>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: Glenn Morris <rgm@gnu.org>, Nick Roberts <nickrob@snap.net.nz>,
rms@gnu.org, emacs-devel@gnu.org
Subject: Re: display-completion-list should not strip text properties
Date: Wed, 11 Apr 2007 18:38:31 +0200 [thread overview]
Message-ID: <87hcrmg92w.fsf@gmx.at> (raw)
In-Reply-To: 87d52ifekm.fsf@stupidchicken.com
Chong Yidong <cyd@stupidchicken.com> 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 <markus.triska@gmx.at>
* 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)
+ \f
+ ;; 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)
next prev parent reply other threads:[~2007-04-11 16:38 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-22 17:23 display-completion-list should not strip text properties Drew Adams
2007-01-22 18:56 ` Stefan Monnier
2007-01-23 2:07 ` Richard Stallman
2007-01-23 5:10 ` Drew Adams
2007-01-23 21:32 ` Drew Adams
2007-01-24 8:22 ` Richard Stallman
2007-01-24 23:43 ` Johan Bockgård
2007-01-25 10:53 ` Richard Stallman
2007-01-26 13:17 ` Vinicius Jose Latorre
2007-01-27 0:46 ` Richard Stallman
2007-09-01 19:56 ` Drew Adams
2007-09-02 18:52 ` Juri Linkov
2007-09-03 18:25 ` Richard Stallman
2007-09-03 23:48 ` Juri Linkov
2007-09-04 5:59 ` David Kastrup
2007-09-04 9:52 ` Juri Linkov
2007-09-04 8:49 ` tomas
2007-09-04 9:54 ` Juri Linkov
2007-09-04 10:56 ` Johan Bockgård
2007-09-04 22:58 ` Richard Stallman
2007-09-04 16:45 ` Richard Stallman
2007-09-04 18:51 ` Drew Adams
2007-09-04 22:46 ` Davis Herring
2007-09-05 6:16 ` Richard Stallman
2007-09-05 14:21 ` Drew Adams
2007-09-06 4:59 ` Richard Stallman
2007-09-06 16:35 ` Drew Adams
2007-09-06 20:04 ` Edward O'Connor
2007-09-06 20:16 ` Drew Adams
2007-09-06 23:08 ` Robert J. Chassell
2007-09-06 23:42 ` Davis Herring
2007-09-07 12:30 ` Robert J. Chassell
2007-09-08 7:00 ` Richard Stallman
2007-09-07 19:53 ` Richard Stallman
2007-09-07 22:07 ` Drew Adams
2007-09-06 20:06 ` David Kastrup
2007-09-06 20:22 ` Drew Adams
2007-09-07 6:31 ` Richard Stallman
2007-09-05 6:16 ` Richard Stallman
2007-03-20 22:36 ` Drew Adams
2007-04-02 16:55 ` Drew Adams
2007-04-02 18:51 ` Kim F. Storm
2007-04-03 21:40 ` Richard Stallman
2007-04-03 21:53 ` Juanma Barranquero
2007-04-04 14:03 ` Richard Stallman
2007-04-03 22:03 ` Nick Roberts
2007-04-04 14:03 ` Richard Stallman
2007-04-04 14:59 ` Chong Yidong
2007-04-05 23:11 ` Richard Stallman
2007-04-05 23:20 ` Chong Yidong
2007-04-06 19:47 ` Richard Stallman
2007-04-05 23:45 ` Nick Roberts
2007-04-06 1:15 ` Glenn Morris
2007-04-06 1:59 ` Chong Yidong
2007-04-06 2:22 ` David Kastrup
2007-04-06 4:18 ` Glenn Morris
2007-04-06 8:41 ` Eli Zaretskii
2007-04-06 14:47 ` Chong Yidong
2007-04-06 16:26 ` Kim F. Storm
2007-04-06 17:34 ` Eli Zaretskii
2007-04-07 12:40 ` Richard Stallman
2007-04-06 17:06 ` Kim F. Storm
2007-04-06 19:23 ` Kevin Rodgers changes Chong Yidong
2007-04-07 7:32 ` martin rudalics
2007-04-07 12:40 ` Richard Stallman
2007-04-07 16:57 ` Chong Yidong
2007-04-07 17:34 ` Eli Zaretskii
2007-04-08 12:28 ` Richard Stallman
2007-04-08 21:07 ` Eli Zaretskii
2007-04-09 14:33 ` Daniel Brockman
2007-04-09 15:42 ` Richard Stallman
2007-04-08 21:30 ` Chong Yidong
2007-04-09 15:42 ` Richard Stallman
2007-04-11 16:38 ` Markus Triska [this message]
2007-04-11 17:13 ` display-completion-list should not strip text properties Chong Yidong
2007-04-06 19:47 ` Richard Stallman
2007-04-06 8:42 ` Eli Zaretskii
2007-04-06 19:47 ` Richard Stallman
2007-04-04 17:45 ` Edward O'Connor
2007-04-05 14:36 ` Chong Yidong
2007-04-05 15:02 ` Juanma Barranquero
2007-04-05 23:11 ` Richard Stallman
2007-01-24 7:07 ` Kevin Rodgers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87hcrmg92w.fsf@gmx.at \
--to=markus.triska@gmx.at \
--cc=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.org \
--cc=nickrob@snap.net.nz \
--cc=rgm@gnu.org \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.