diff options
| author | Mattias EngdegÄrd | 2019-05-21 12:19:38 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2019-06-19 11:20:58 +0200 |
| commit | b8c74742c0238fe15b1cdc9a7f6ee021d038368f (patch) | |
| tree | d2d51fb226584f28017cb04ef8c3d173e83f1e87 /test | |
| parent | 36ab408207d7adf94fd1396922e0df38d746a948 (diff) | |
| download | emacs-b8c74742c0238fe15b1cdc9a7f6ee021d038368f.tar.gz emacs-b8c74742c0238fe15b1cdc9a7f6ee021d038368f.zip | |
Tighter pcase or-pattern member function selection (bug#36139)
* lisp/emacs-lisp/pcase.el (pcase--u1):
Use the most specific of `memq', `memql' and `member' in or-patterns
with constant cases. This improves performance and may help the byte-code
compiler generate a switch.
* test/lisp/emacs-lisp/pcase-tests.el (pcase-tests-member):
Add mixed-type or-pattern test cases.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/pcase-tests.el | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/lisp/emacs-lisp/pcase-tests.el b/test/lisp/emacs-lisp/pcase-tests.el index af8c9a3f3c3..e8c0b8219c5 100644 --- a/test/lisp/emacs-lisp/pcase-tests.el +++ b/test/lisp/emacs-lisp/pcase-tests.el | |||
| @@ -51,9 +51,11 @@ | |||
| 51 | 51 | ||
| 52 | (ert-deftest pcase-tests-member () | 52 | (ert-deftest pcase-tests-member () |
| 53 | (should (pcase-tests-grep | 53 | (should (pcase-tests-grep |
| 54 | 'memql (macroexpand-all '(pcase x ((or 1 2 3) body))))) | 54 | 'memq (macroexpand-all '(pcase x ((or 'a 'b 'c) body))))) |
| 55 | (should (pcase-tests-grep | 55 | (should (pcase-tests-grep |
| 56 | 'member (macroexpand-all '(pcase x ((or "a" 2 3) body))))) | 56 | 'memql (macroexpand-all '(pcase x ((or 1 2 3 'a) body))))) |
| 57 | (should (pcase-tests-grep | ||
| 58 | 'member (macroexpand-all '(pcase x ((or "a" 2 3 'a) body))))) | ||
| 57 | (should-not (pcase-tests-grep | 59 | (should-not (pcase-tests-grep |
| 58 | 'memq (macroexpand-all '(pcase x ((or "a" 2 3) body))))) | 60 | 'memq (macroexpand-all '(pcase x ((or "a" 2 3) body))))) |
| 59 | (should-not (pcase-tests-grep | 61 | (should-not (pcase-tests-grep |