aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/byte-opt.el29
1 files changed, 21 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index c955a6aa0f2..24770a12197 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1,9 +1,10 @@
1;;; byte-opt.el --- the optimization passes of the emacs-lisp byte compiler. 1;;; byte-opt.el --- the optimization passes of the emacs-lisp byte compiler.
2 2
3;;; Copyright (c) 1991, 1994 Free Software Foundation, Inc. 3;;; Copyright (c) 1991, 1994, 2000 Free Software Foundation, Inc.
4 4
5;; Author: Jamie Zawinski <jwz@lucid.com> 5;; Author: Jamie Zawinski <jwz@lucid.com>
6;; Hallvard Furuseth <hbf@ulrik.uio.no> 6;; Hallvard Furuseth <hbf@ulrik.uio.no>
7;; Maintainer: FSF
7;; Keywords: internal 8;; Keywords: internal
8 9
9;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
@@ -592,9 +593,10 @@
592;; I'd like this to be a defsubst, but let's not be self-referential... 593;; I'd like this to be a defsubst, but let's not be self-referential...
593(defmacro byte-compile-trueconstp (form) 594(defmacro byte-compile-trueconstp (form)
594 ;; Returns non-nil if FORM is a non-nil constant. 595 ;; Returns non-nil if FORM is a non-nil constant.
595 (` (cond ((consp (, form)) (eq (car (, form)) 'quote)) 596 `(cond ((consp ,form) (eq (car ,form) 'quote))
596 ((not (symbolp (, form)))) 597 ((not (symbolp ,form)))
597 ((eq (, form) t))))) 598 ((eq ,form t))
599 ((keywordp ,form))))
598 600
599;; If the function is being called with constant numeric args, 601;; If the function is being called with constant numeric args,
600;; evaluate as much as possible at compile-time. This optimizer 602;; evaluate as much as possible at compile-time. This optimizer
@@ -895,7 +897,7 @@
895(defun byte-optimize-quote (form) 897(defun byte-optimize-quote (form)
896 (if (or (consp (nth 1 form)) 898 (if (or (consp (nth 1 form))
897 (and (symbolp (nth 1 form)) 899 (and (symbolp (nth 1 form))
898 (not (memq (nth 1 form) '(nil t))))) 900 (not (byte-compile-const-symbol-p form))))
899 form 901 form
900 (nth 1 form))) 902 (nth 1 form)))
901 903
@@ -1116,6 +1118,14 @@
1116 ((= 1 (safe-length form)) 1118 ((= 1 (safe-length form))
1117 '(forward-char -1)) 1119 '(forward-char -1))
1118 (t form))) 1120 (t form)))
1121
1122(put 'char-before 'byte-optimizer 'byte-optimize-char-before)
1123(defun byte-optimize-char-before (form)
1124 (cond ((= 2 (safe-length form))
1125 `(char-after (1- ,(nth 1 form))))
1126 ((= 1 (safe-length form))
1127 '(char-after (1- (point))))
1128 (t form)))
1119 1129
1120;;; enumerating those functions which need not be called if the returned 1130;;; enumerating those functions which need not be called if the returned
1121;;; value is not used. That is, something like 1131;;; value is not used. That is, something like
@@ -1132,7 +1142,8 @@
1132 assoc assq 1142 assoc assq
1133 boundp buffer-file-name buffer-local-variables buffer-modified-p 1143 boundp buffer-file-name buffer-local-variables buffer-modified-p
1134 buffer-substring 1144 buffer-substring
1135 capitalize car-less-than-car car cdr ceiling concat coordinates-in-window-p 1145 capitalize car-less-than-car car cdr ceiling concat
1146 coordinates-in-window-p
1136 char-width copy-marker cos count-lines 1147 char-width copy-marker cos count-lines
1137 default-boundp default-value documentation downcase 1148 default-boundp default-value documentation downcase
1138 elt exp expt fboundp featurep 1149 elt exp expt fboundp featurep
@@ -1143,7 +1154,8 @@
1143 hash-table-count 1154 hash-table-count
1144 int-to-string 1155 int-to-string
1145 keymap-parent 1156 keymap-parent
1146 length local-variable-if-set-p local-variable-p log log10 logand logb logior lognot logxor lsh 1157 length local-variable-if-set-p local-variable-p log log10 logand
1158 logb logior lognot logxor lsh
1147 marker-buffer max member memq min mod 1159 marker-buffer max member memq min mod
1148 next-window nth nthcdr number-to-string 1160 next-window nth nthcdr number-to-string
1149 parse-colon-path prefix-numeric-value previous-window 1161 parse-colon-path prefix-numeric-value previous-window
@@ -1484,7 +1496,8 @@
1484 (if (memq (car lap0) '(byte-constant byte-dup)) 1496 (if (memq (car lap0) '(byte-constant byte-dup))
1485 (progn 1497 (progn
1486 (setq tmp (if (or (not tmp) 1498 (setq tmp (if (or (not tmp)
1487 (memq (car (cdr lap0)) '(nil t))) 1499 (byte-compile-const-symbol-p
1500 (car (cdr lap0))))
1488 (cdr lap0) 1501 (cdr lap0)
1489 (byte-compile-get-constant t))) 1502 (byte-compile-get-constant t)))
1490 (byte-compile-log-lap " %s %s %s\t-->\t%s %s %s" 1503 (byte-compile-log-lap " %s %s %s\t-->\t%s %s %s"