mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-10 00:00:39 -08:00
Compile any subsequence of `cond' clauses to switch (bug#36139)
A single `cond' form can how be compiled to any number of switch ops, optionally interspersed with non-switch conditions. Previously, switch ops would only be used for whole `cond' forms containing no other tests. * lisp/emacs-lisp/bytecomp.el (byte-compile--cond-vars): Rename from `byte-compile-cond-vars'. (byte-compile--default-val): Remove. (byte-compile--cond-switch-prefix): Replace `byte-compile-cond-jump-table-info'; now also returns trailing non-switch clauses. (byte-compile-cond-jump-table): New arguments; no longer compiles the default case. (byte-compile-cond): Look for and compile switches at any place in the list of clauses. * test/lisp/emacs-lisp/bytecomp-tests.el (byte-opt-testsuite-arith-data): Add test expression.
This commit is contained in:
parent
14a81524c2
commit
d3a7f3e6cd
2 changed files with 170 additions and 175 deletions
|
|
@ -334,7 +334,20 @@
|
|||
((memql x '(9 0.5 1.5 q)) 66)
|
||||
(t 99)))
|
||||
'(a b c d (d) (a . b) "X" 0.5 1.5 3.14 9 9.0))
|
||||
)
|
||||
;; Multi-switch cond form
|
||||
(mapcar (lambda (p) (let ((x (car p)) (y (cadr p)))
|
||||
(cond ((consp x) 11)
|
||||
((eq x 'a) 22)
|
||||
((memql x '(b 7 a -3)) 33)
|
||||
((equal y "a") 44)
|
||||
((memq y '(c d e)) 55)
|
||||
((booleanp x) 66)
|
||||
((eq x 'q) 77)
|
||||
((memq x '(r s)) 88)
|
||||
((eq x 't) 99)
|
||||
(t 999))))
|
||||
'((a c) (b c) (7 c) (-3 c) (nil nil) (t c) (q c) (r c) (s c)
|
||||
(t c) (x "a") (x "c") (x c) (x d) (x e))))
|
||||
"List of expression for test.
|
||||
Each element will be executed by interpreter and with
|
||||
bytecompiled code, and their results compared.")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue