diff options
| author | Mattias EngdegÄrd | 2019-06-07 17:04:10 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2019-06-19 11:22:21 +0200 |
| commit | d3a7f3e6cd0124e62ed2b5ffc87eee57fee39a9a (patch) | |
| tree | 865b52b1a0a33438b35a766de7198cea8aea3488 /test | |
| parent | 14a81524c27ab54850e0fda736e4ee0c92e447b5 (diff) | |
| download | emacs-d3a7f3e6cd0124e62ed2b5ffc87eee57fee39a9a.tar.gz emacs-d3a7f3e6cd0124e62ed2b5ffc87eee57fee39a9a.zip | |
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.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 0f18a34578d..5bd36898702 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el | |||
| @@ -334,7 +334,20 @@ | |||
| 334 | ((memql x '(9 0.5 1.5 q)) 66) | 334 | ((memql x '(9 0.5 1.5 q)) 66) |
| 335 | (t 99))) | 335 | (t 99))) |
| 336 | '(a b c d (d) (a . b) "X" 0.5 1.5 3.14 9 9.0)) | 336 | '(a b c d (d) (a . b) "X" 0.5 1.5 3.14 9 9.0)) |
| 337 | ) | 337 | ;; Multi-switch cond form |
| 338 | (mapcar (lambda (p) (let ((x (car p)) (y (cadr p))) | ||
| 339 | (cond ((consp x) 11) | ||
| 340 | ((eq x 'a) 22) | ||
| 341 | ((memql x '(b 7 a -3)) 33) | ||
| 342 | ((equal y "a") 44) | ||
| 343 | ((memq y '(c d e)) 55) | ||
| 344 | ((booleanp x) 66) | ||
| 345 | ((eq x 'q) 77) | ||
| 346 | ((memq x '(r s)) 88) | ||
| 347 | ((eq x 't) 99) | ||
| 348 | (t 999)))) | ||
| 349 | '((a c) (b c) (7 c) (-3 c) (nil nil) (t c) (q c) (r c) (s c) | ||
| 350 | (t c) (x "a") (x "c") (x c) (x d) (x e)))) | ||
| 338 | "List of expression for test. | 351 | "List of expression for test. |
| 339 | Each element will be executed by interpreter and with | 352 | Each element will be executed by interpreter and with |
| 340 | bytecompiled code, and their results compared.") | 353 | bytecompiled code, and their results compared.") |