[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 0724c6dbdae: Use string-search instead of string-match[-p] wh
From: |
Robert Pluim |
Subject: |
Re: master 0724c6dbdae: Use string-search instead of string-match[-p] when possible |
Date: |
Wed, 29 Mar 2023 17:23:03 +0200 |
>>>>> On Sun, 26 Mar 2023 06:47:54 -0400 (EDT), Mattias Engdegård
>>>>> <mattiase@acm.org> said:
Mattias> branch: master
Mattias> commit 0724c6dbdaef2c549409836ba4f7999e05aa31fe
Mattias> Author: Mattias Engdegård <mattiase@acm.org>
Mattias> Commit: Mattias Engdegård <mattiase@acm.org>
Mattias> Use string-search instead of string-match[-p] when possible
Mattias> * lisp/progmodes/c-ts-mode.el
Mattias> (c-ts-mode--standalone-parent-skip-preproc):
Mattias> * lisp/progmodes/ruby-ts-mode.el (ruby-ts--align-chain):
Mattias> * lisp/treesit.el (treesit-max-buffer-size)
Mattias> (treesit--check-manual-coverage):
Mattias> Use the much faster string-search when just searching for a
substring.
Mattias> ---
Mattias> lisp/progmodes/c-ts-mode.el | 2 +-
Mattias> lisp/progmodes/ruby-ts-mode.el | 2 +-
Mattias> lisp/treesit.el | 4 ++--
Mattias> 3 files changed, 4 insertions(+), 4 deletions(-)
Hmm, we could do this using a compiler macro, no? Something like
(put 'string-match-p 'compiler-macro
#'byte-optimize-string-match-p)
(defun byte-optimize-string-match-p (form r string &optional start)
(if (and (stringp r)
(string-equal r (regexp-quote r)))
`(string-search ,r ,string ,start)
form))
(I donʼt think we can do it unconditionally for `string-match', since
`string-search' doesnʼt set the match data.)
Robert
--