all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: emacs-devel@gnu.org
Cc: "Mattias Engdegård" <mattiase@acm.org>
Subject: Re: master 0724c6dbdae: Use string-search instead of string-match[-p] when possible
Date: Wed, 29 Mar 2023 17:23:03 +0200	[thread overview]
Message-ID: <875yajmvjc.fsf@gmail.com> (raw)
In-Reply-To: <20230326104755.356B1C1391D@vcs2.savannah.gnu.org> ("Mattias Engdegård"'s message of "Sun, 26 Mar 2023 06:47:54 -0400 (EDT)")

>>>>> 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
-- 



  parent reply	other threads:[~2023-03-29 15:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <167982767456.13549.3313290435008922358@vcs2.savannah.gnu.org>
     [not found] ` <20230326104755.356B1C1391D@vcs2.savannah.gnu.org>
2023-03-26 23:05   ` master 0724c6dbdae: Use string-search instead of string-match[-p] when possible Dmitry Gutov
2023-03-26 23:35     ` Emanuel Berg
2023-03-27  4:58       ` Yuan Fu
2023-03-27 12:47     ` Mattias Engdegård
2023-03-29 15:23   ` Robert Pluim [this message]
2023-03-29 15:34     ` Mattias Engdegård
2023-03-29 15:54       ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yajmvjc.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=mattiase@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.