aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMattias Engdegård2019-10-09 10:22:10 +0200
committerMattias Engdegård2019-10-18 14:46:12 +0200
commit6331d23de3a861de2374be2c03b42e3a2f150792 (patch)
tree1efa44e4818ae482688a3872154592597eed6488 /test
parentae5407b8579feae17ab34ed9ac68149cc29387c9 (diff)
downloademacs-6331d23de3a861de2374be2c03b42e3a2f150792.tar.gz
emacs-6331d23de3a861de2374be2c03b42e3a2f150792.zip
Use [^z-a] for matching any character (anychar/anything) in rx
* lisp/emacs-lisp/rx.el (rx--translate-symbol): * test/lisp/emacs-lisp/rx-tests.el (rx-any, rx-atoms): Use [^z-a] instead of ".\\|\n" for anychar. The new expression is faster (about 2×) and does not allocate regexp stack space. For example, (0+ anychar) now matches strings of any size (bug#37659).
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/rx-tests.el6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el
index 903b191c98e..ef2541d83af 100644
--- a/test/lisp/emacs-lisp/rx-tests.el
+++ b/test/lisp/emacs-lisp/rx-tests.el
@@ -126,9 +126,9 @@
126 (should (equal (rx (not (any "!a" "0-8" digit nonascii))) 126 (should (equal (rx (not (any "!a" "0-8" digit nonascii)))
127 "[^!0-8a[:digit:][:nonascii:]]")) 127 "[^!0-8a[:digit:][:nonascii:]]"))
128 (should (equal (rx (any) (not (any))) 128 (should (equal (rx (any) (not (any)))
129 "\\`a\\`\\(?:.\\|\n\\)")) 129 "\\`a\\`[^z-a]"))
130 (should (equal (rx (any "") (not (any ""))) 130 (should (equal (rx (any "") (not (any "")))
131 "\\`a\\`\\(?:.\\|\n\\)"))) 131 "\\`a\\`[^z-a]")))
132 132
133(ert-deftest rx-pcase () 133(ert-deftest rx-pcase ()
134 (should (equal (pcase "a 1 2 3 1 1 b" 134 (should (equal (pcase "a 1 2 3 1 1 b"
@@ -185,7 +185,7 @@
185 185
186(ert-deftest rx-atoms () 186(ert-deftest rx-atoms ()
187 (should (equal (rx anychar anything) 187 (should (equal (rx anychar anything)
188 "\\(?:.\\|\n\\)\\(?:.\\|\n\\)")) 188 "[^z-a][^z-a]"))
189 (should (equal (rx unmatchable) 189 (should (equal (rx unmatchable)
190 "\\`a\\`")) 190 "\\`a\\`"))
191 (should (equal (rx line-start not-newline nonl any line-end) 191 (should (equal (rx line-start not-newline nonl any line-end)