[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/gnus-select 2f67ad3 208/218: Optimize certain memq
From: |
Andrew G Cohen |
Subject: |
[Emacs-diffs] feature/gnus-select 2f67ad3 208/218: Optimize certain memq forms during byte-compilation. |
Date: |
Fri, 14 Dec 2018 03:35:45 -0500 (EST) |
branch: feature/gnus-select
commit 2f67ad35d7d6dac283093b6daa6d8cad94c9df9b
Author: Vibhav Pant <address@hidden>
Commit: Andrew G Cohen <address@hidden>
Optimize certain memq forms during byte-compilation.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-memq): New function.
Set the byte optimizer function for memq to byte-optimize-memq.
---
lisp/emacs-lisp/byte-opt.el | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index a5e0e21..54421e0 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -764,7 +764,23 @@
(if (= 1 (length (cdr form))) "" "s"))
form))
+(defun byte-optimize-memq (form)
+ ;; (memq foo '(bar)) => (and (eq foo 'bar) '(bar))
+ (if (/= (length (cdr form)) 2)
+ (byte-compile-warn "memq called with %d arg%s, but requires 2"
+ (length (cdr form))
+ (if (= 1 (length (cdr form))) "" "s"))
+ (let ((list (nth 2 form)))
+ (when (and (eq (car-safe list) 'quote)
+ (listp (setq list (cadr list)))
+ (= (length list) 1))
+ (setq form `(and ,(byte-optimize-predicate
+ `(eq ,(nth 1 form) ',(nth 0 list)))
+ ',list))))
+ (byte-optimize-and form)))
+
(put 'identity 'byte-optimizer 'byte-optimize-identity)
+(put 'memq 'byte-optimizer 'byte-optimize-memq)
(put '+ 'byte-optimizer 'byte-optimize-plus)
(put '* 'byte-optimizer 'byte-optimize-multiply)
@@ -787,7 +803,6 @@
(put '1- 'byte-optimizer 'byte-optimize-predicate)
(put 'not 'byte-optimizer 'byte-optimize-predicate)
(put 'null 'byte-optimizer 'byte-optimize-predicate)
-(put 'memq 'byte-optimizer 'byte-optimize-predicate)
(put 'consp 'byte-optimizer 'byte-optimize-predicate)
(put 'listp 'byte-optimizer 'byte-optimize-predicate)
(put 'symbolp 'byte-optimizer 'byte-optimize-predicate)
@@ -805,7 +820,6 @@
(put 'car-safe 'byte-optimizer 'byte-optimize-predicate)
(put 'cdr-safe 'byte-optimizer 'byte-optimize-predicate)
-
;; I'm not convinced that this is necessary. Doesn't the optimizer loop
;; take care of this? - Jamie
;; I think this may some times be necessary to reduce ie (quote 5) to 5,
- [Emacs-diffs] feature/gnus-select 219d6cf 180/218: * doc/lispref/anti.texi (Antinews): Fix grammar., (continued)
- [Emacs-diffs] feature/gnus-select 219d6cf 180/218: * doc/lispref/anti.texi (Antinews): Fix grammar., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 7f60bfe 175/218: Port emacs-module-tests to 32-bit Emacs, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 9fabadf 179/218: Add new command vc-git-stash-delete, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 3ff0a07 182/218: Try and fix the more obvious sources of bug#30635, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 4a80595 192/218: Fix too-large integer in Hg backend, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 992a8ec 187/218: * src/lisp.h (struct Lisp_Buffer_Local_Value): Update commentary., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 17a41a9 191/218: Avoid Fortran-style floating-point optimization, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 6eddea6 193/218: * src/process.c (Fsignal_process): Simplify., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 80ab319 204/218: Remove some unused gnus-registry variables, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 905bb9c 206/218: * lisp/emulation/viper.el (viper-set-hooks): Replace obsolete func., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 2f67ad3 208/218: Optimize certain memq forms during byte-compilation.,
Andrew G Cohen <=
- [Emacs-diffs] feature/gnus-select bc2d36a 197/218: Remove some declare-function stub definitions, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 39699c8 212/218: Remove architecture dependent source downloads, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select c5595a1 200/218: * lisp/progmodes/cc-langs.el: Silence compiler., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 8912ca0 211/218: Make eshell/kill handle -<signal> and -<SIGNALNAME> (Bug#29156), Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 4b68a75 216/218: ; Spelling fix, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 2e4c1b9 196/218: Replace some uses of cl with cl-lib, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 709e1da 189/218: Fix bug#30846, along with misc cleanups found along the way, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 8ee4b77 194/218: cedet: replace cl with cl-lib, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 5b0fed9 218/218: Fix constant folding of overflows, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 1955afe 162/218: * lisp/gnus/gnus-cloud.el (gnus-cloud-synced-files): Fix doc & type., Andrew G Cohen, 2018/12/14