diff options
| author | Mattias Engdegård | 2020-11-19 14:24:24 +0100 |
|---|---|---|
| committer | Mattias Engdegård | 2020-11-19 14:58:48 +0100 |
| commit | 90aab73f8d6b5fd0a8adb706c8ae669564f23c56 (patch) | |
| tree | 08e62c3c7a97b0c6b531a70785b26b8f4505ae79 /test/src | |
| parent | 74a35d16e25bdb07d847b980008fc4d25ab9404e (diff) | |
| download | emacs-90aab73f8d6b5fd0a8adb706c8ae669564f23c56.tar.gz emacs-90aab73f8d6b5fd0a8adb706c8ae669564f23c56.zip | |
More string-search optimisations
All-ASCII strings cannot have substrings with non-ASCII characters in
them; use this fact to avoid searching entirely.
* src/fns.c (Fstring_search): For multibyte non-ASCII needle and
unibyte haystack, don't check if the haystack is all-ASCII; it's a
waste of time. For multibyte non-ASCII needle and multibyte
all-ASCII haystack, fail immediately.
* test/src/fns-tests.el (string-search): Add more test cases.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/fns-tests.el | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index d3c22f966e6..86b8d655d26 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -938,6 +938,13 @@ | |||
| 938 | (should (equal (string-search "\303" "aøb") nil)) | 938 | (should (equal (string-search "\303" "aøb") nil)) |
| 939 | (should (equal (string-search "\270" "aøb") nil)) | 939 | (should (equal (string-search "\270" "aøb") nil)) |
| 940 | (should (equal (string-search "ø" "\303\270") nil)) | 940 | (should (equal (string-search "ø" "\303\270") nil)) |
| 941 | (should (equal (string-search "ø" (make-string 32 ?a)) nil)) | ||
| 942 | (should (equal (string-search "ø" (string-to-multibyte (make-string 32 ?a))) | ||
| 943 | nil)) | ||
| 944 | (should (equal (string-search "o" (string-to-multibyte | ||
| 945 | (apply #'string | ||
| 946 | (number-sequence ?a ?z)))) | ||
| 947 | 14)) | ||
| 941 | 948 | ||
| 942 | (should (equal (string-search "a\U00010f98z" "a\U00010f98a\U00010f98z") 2)) | 949 | (should (equal (string-search "a\U00010f98z" "a\U00010f98a\U00010f98z") 2)) |
| 943 | 950 | ||