aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2023-03-26 12:09:41 +0200
committerMattias EngdegÄrd2023-03-26 12:09:41 +0200
commit0724c6dbdaef2c549409836ba4f7999e05aa31fe (patch)
tree2508e2bafc19f4b6529112a51da384eb520e14bd
parenta27b0f7f307ccf54fd5910a0655bd72b23e69fcf (diff)
downloademacs-0724c6dbdaef2c549409836ba4f7999e05aa31fe.tar.gz
emacs-0724c6dbdaef2c549409836ba4f7999e05aa31fe.zip
Use string-search instead of string-match[-p] when possible
* lisp/progmodes/c-ts-mode.el (c-ts-mode--standalone-parent-skip-preproc): * lisp/progmodes/ruby-ts-mode.el (ruby-ts--align-chain): * lisp/treesit.el (treesit-max-buffer-size) (treesit--check-manual-coverage): Use the much faster string-search when just searching for a substring.
-rw-r--r--lisp/progmodes/c-ts-mode.el2
-rw-r--r--lisp/progmodes/ruby-ts-mode.el2
-rw-r--r--lisp/treesit.el4
3 files changed, 4 insertions, 4 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 59eb9fc23e6..d773b4a41f4 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -322,7 +322,7 @@ PARENT is the same as other anchor functions."
322 ;; nil. 322 ;; nil.
323 parent (lambda (node) 323 parent (lambda (node)
324 (and node 324 (and node
325 (not (string-match "preproc" (treesit-node-type node))) 325 (not (string-search "preproc" (treesit-node-type node)))
326 (progn 326 (progn
327 (goto-char (treesit-node-start node)) 327 (goto-char (treesit-node-start node))
328 (looking-back (rx bol (* whitespace)) 328 (looking-back (rx bol (* whitespace))
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index d077c43ba52..d1034d467ab 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -469,7 +469,7 @@ non-nil."
469 (let* (first-call ) 469 (let* (first-call )
470 (while (and parent 470 (while (and parent
471 (setq first-call (treesit-node-parent parent)) 471 (setq first-call (treesit-node-parent parent))
472 (string-match-p "call" (treesit-node-type first-call))) 472 (string-search "call" (treesit-node-type first-call)))
473 (setq parent first-call)) 473 (setq parent first-call))
474 (treesit-node-start (treesit-search-subtree parent "\\." nil t)))) 474 (treesit-node-start (treesit-search-subtree parent "\\." nil t))))
475 475
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 367d2c66ac7..2b0eca7f5c2 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -106,7 +106,7 @@ indent, imenu, etc."
106 ;; 40MB for 64-bit systems, 15 for 32-bit. 106 ;; 40MB for 64-bit systems, 15 for 32-bit.
107 (if (or (< most-positive-fixnum (* 2.0 1024 mb)) 107 (if (or (< most-positive-fixnum (* 2.0 1024 mb))
108 ;; 32-bit system with wide ints. 108 ;; 32-bit system with wide ints.
109 (string-match-p "--with-wide-int" system-configuration-options)) 109 (string-search "--with-wide-int" system-configuration-options))
110 (* 15 mb) 110 (* 15 mb)
111 (* 40 mb))) 111 (* 40 mb)))
112 "Maximum buffer size (in bytes) for enabling tree-sitter parsing. 112 "Maximum buffer size (in bytes) for enabling tree-sitter parsing.
@@ -3090,7 +3090,7 @@ function signals an error."
3090 (with-temp-buffer 3090 (with-temp-buffer
3091 (insert-file-contents (find-library-name "treesit")) 3091 (insert-file-contents (find-library-name "treesit"))
3092 (cl-remove-if 3092 (cl-remove-if
3093 (lambda (name) (string-match "treesit--" name)) 3093 (lambda (name) (string-search "treesit--" name))
3094 (cl-sort 3094 (cl-sort
3095 (save-excursion 3095 (save-excursion
3096 (goto-char (point-min)) 3096 (goto-char (point-min))