From: Mattias EngdegÄrd Date: Sun, 26 Mar 2023 10:09:41 +0000 (+0200) Subject: Use string-search instead of string-match[-p] when possible X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0724c6dbdaef2c549409836ba4f7999e05aa31fe;p=emacs.git 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. --- 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." ;; nil. parent (lambda (node) (and node - (not (string-match "preproc" (treesit-node-type node))) + (not (string-search "preproc" (treesit-node-type node))) (progn (goto-char (treesit-node-start node)) (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." (let* (first-call ) (while (and parent (setq first-call (treesit-node-parent parent)) - (string-match-p "call" (treesit-node-type first-call))) + (string-search "call" (treesit-node-type first-call))) (setq parent first-call)) (treesit-node-start (treesit-search-subtree parent "\\." nil t)))) 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." ;; 40MB for 64-bit systems, 15 for 32-bit. (if (or (< most-positive-fixnum (* 2.0 1024 mb)) ;; 32-bit system with wide ints. - (string-match-p "--with-wide-int" system-configuration-options)) + (string-search "--with-wide-int" system-configuration-options)) (* 15 mb) (* 40 mb))) "Maximum buffer size (in bytes) for enabling tree-sitter parsing. @@ -3090,7 +3090,7 @@ function signals an error." (with-temp-buffer (insert-file-contents (find-library-name "treesit")) (cl-remove-if - (lambda (name) (string-match "treesit--" name)) + (lambda (name) (string-search "treesit--" name)) (cl-sort (save-excursion (goto-char (point-min))