From: Lars Ingebrigtsen <larsi@gnus.org>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: Shigeru Fukaya <shigeru.fukaya@gmail.com>,
44861-done@debbugs.gnu.org,
Stefan Kangas <stefankangas@gmail.com>,
Dmitry Gutov <dgutov@yandex.ru>
Subject: bug#44861: 27.1; [PATCH] signal in `replace-regexp-in-string'
Date: Thu, 26 Nov 2020 15:03:30 +0100 [thread overview]
Message-ID: <87zh34p64t.fsf@gnus.org> (raw)
In-Reply-To: <C136B0DC-1CC5-499E-8BBD-14EAF9E2A4EB@acm.org> ("Mattias Engdegård"'s message of "Thu, 26 Nov 2020 14:39:01 +0100")
Mattias Engdegård <mattiase@acm.org> writes:
> Probably, but that would be a pure performance improvement. Most of
> the time is currently consumed in primitives (string-match,
> replace-match, substring, concat) so don't expect huge savings unless
> a substantially different approach is taken.
Yeah, perhaps there's isn't a lot to be gained there, unless a lot of
the re-checking of all the arguments (etc.) (which is unnecessary once
we've ascertained that everything is, indeed, a string) can be done by
refactoring some of the underlying primitives.
> (Dmitry Gutov asked for a C implementation in bug#20273 for improving
> the speed of json encoding; is that still relevant?)
No, probably not, since it's now done by Jansson? So I'm closing that
one.
> A bigger saving yet would be to use the much faster string-replace
> wherever possible. A little sweeping refactoring project perhaps? It
> would also improve readability -- no regexp quoting, fewer mysterious
> arguments like LITERAL and FIXEDCASE to worry about, etc.
I started looking at that, and there's a huge pile of calls like
(replace-regexp-in-string ":" ";" string)
that can be rewritten to use string-replace. But! Every single case
requires careful analysis, exactly because replace-regexp-in-string sets
the match data. Perhaps five lines later, there's a reference to
(match-string 0 string)? Perhaps the reference is in the function that
called this function?
So most changes are fraught with possible unforeseen breakages, the code
is super-duper straightforward like
(setq string (replace-regexp-in-string ":" ";" string))
(setq string (replace-regexp-in-string "a" "b" string))
Then you know that you can replace the first one without any danger.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2020-11-26 14:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-25 4:02 bug#44861: 27.1; [PATCH] signal in `replace-regexp-in-string' Shigeru Fukaya
2020-11-25 10:58 ` Mattias Engdegård
2020-11-25 14:58 ` Mattias Engdegård
2020-11-25 21:39 ` Stefan Kangas
2020-11-26 12:57 ` Mattias Engdegård
2020-11-26 13:12 ` Lars Ingebrigtsen
2020-11-26 13:39 ` Mattias Engdegård
2020-11-26 14:03 ` Lars Ingebrigtsen [this message]
2020-11-26 14:54 ` Mattias Engdegård
2020-11-29 13:28 ` Basil L. Contovounesios
2020-11-26 13:43 ` Stefan Kangas
2020-11-26 14:03 ` Lars Ingebrigtsen
2020-11-26 14:41 ` Eli Zaretskii
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=87zh34p64t.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=44861-done@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
--cc=mattiase@acm.org \
--cc=shigeru.fukaya@gmail.com \
--cc=stefankangas@gmail.com \
/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.