[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: display-completion-list should not strip text properties
From: |
Markus Triska |
Subject: |
Re: display-completion-list should not strip text properties |
Date: |
Wed, 11 Apr 2007 18:38:31 +0200 |
Chong Yidong <address@hidden> 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 <address@hidden>
* 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)
- Re: Kevin Rodgers changes, (continued)
- Re: Kevin Rodgers changes, martin rudalics, 2007/04/07
- Re: Kevin Rodgers changes, Richard Stallman, 2007/04/07
- Re: Kevin Rodgers changes, Chong Yidong, 2007/04/07
- Re: Kevin Rodgers changes, Eli Zaretskii, 2007/04/07
- Re: Kevin Rodgers changes, Richard Stallman, 2007/04/08
- Re: Kevin Rodgers changes, Eli Zaretskii, 2007/04/08
- Re: Kevin Rodgers changes, Daniel Brockman, 2007/04/09
- Re: Kevin Rodgers changes, Richard Stallman, 2007/04/09
- Re: Kevin Rodgers changes, Chong Yidong, 2007/04/08
- Re: Kevin Rodgers changes, Richard Stallman, 2007/04/09
- Re: display-completion-list should not strip text properties,
Markus Triska <=
- Re: display-completion-list should not strip text properties, Chong Yidong, 2007/04/11
- Re: display-completion-list should not strip text properties, Richard Stallman, 2007/04/06
- Re: display-completion-list should not strip text properties, Eli Zaretskii, 2007/04/06
- Re: display-completion-list should not strip text properties, Richard Stallman, 2007/04/06
- Re: display-completion-list should not strip text properties, Edward O'Connor, 2007/04/04
- Re: display-completion-list should not strip text properties, Chong Yidong, 2007/04/05
- Re: display-completion-list should not strip text properties, Juanma Barranquero, 2007/04/05
- Re: display-completion-list should not strip text properties, Richard Stallman, 2007/04/05