From: Philip Kaludercic <philipk@posteo.net>
To: emacs-devel@gnu.org
Cc: Daniel Mendler <mail@daniel-mendler.de>
Subject: Re: [elpa] externals/compat 6a60af22da: Optimize string-search
Date: Fri, 11 Aug 2023 06:07:32 +0000 [thread overview]
Message-ID: <87jzu2jemz.fsf@posteo.net> (raw)
In-Reply-To: <20230809135738.457BDC038BF@vcs2.savannah.gnu.org> (ELPA Syncer's message of "Wed, 9 Aug 2023 09:57:38 -0400 (EDT)")
ELPA Syncer <elpasync@gnu.org> writes:
> branch: externals/compat
> commit 6a60af22da1f1a7b08457a4016b9412a475afe4a
> Author: Daniel Mendler <mail@daniel-mendler.de>
> Commit: Daniel Mendler <mail@daniel-mendler.de>
>
> Optimize string-search
> ---
> compat-28.el | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/compat-28.el b/compat-28.el
> index fe69315522..b305ab2fff 100644
> --- a/compat-28.el
> +++ b/compat-28.el
> @@ -52,9 +52,8 @@ issues are inherited."
> (when (and start-pos (or (< (length haystack) start-pos)
> (< start-pos 0)))
> (signal 'args-out-of-range (list start-pos)))
> - (save-match-data
> - (let ((case-fold-search nil))
> - (string-match (regexp-quote needle) haystack start-pos))))
> + (let (case-fold-search)
> + (string-match-p (regexp-quote needle) haystack start-pos)))
>
> (compat-defun length= (sequence length) ;; [[compat-tests:length=]]
> "Returns non-nil if SEQUENCE has a length equal to LENGTH."
I don't believe this is a legal optimisation, even if the regular
expression is quoted. Consider
(progn
(string-match (rx (* "a") (group (* "b")) (* "a")) "abba")
(match-data))
; => (0 4 1 3)
and
(progn
(string-match (rx (* "a") (group (* "b")) (* "a")) "abba")
(string-search "foo" "foobar")
(match-data))
; => (0 4 1 3)
but
(progn
(string-match (rx (* "a") (group (* "b")) (* "a")) "abba")
(let ((case-fold-search nil))
(string-match (regexp-quote "foo") "foobar" 0))
(match-data))
; => (0 3)
next parent reply other threads:[~2023-08-11 6:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <169158945793.6388.8459711282582712176@vcs2.savannah.gnu.org>
[not found] ` <20230809135738.457BDC038BF@vcs2.savannah.gnu.org>
2023-08-11 6:07 ` Philip Kaludercic [this message]
2023-08-11 6:23 ` [elpa] externals/compat 6a60af22da: Optimize string-search Eli Zaretskii
2023-08-11 8:15 ` Philip Kaludercic
2023-08-11 7:12 ` Daniel Mendler
2023-08-11 8:17 ` Philip Kaludercic
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=87jzu2jemz.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=emacs-devel@gnu.org \
--cc=mail@daniel-mendler.de \
/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.