emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#43598: closed (replace-in-string: finishing touches)


From: GNU bug Tracking System
Subject: bug#43598: closed (replace-in-string: finishing touches)
Date: Sun, 27 Sep 2020 16:15:02 +0000

Your message dated Sun, 27 Sep 2020 18:14:36 +0200
with message-id <0DD2B3C3-8ADA-4F90-815C-84D27AE03344@acm.org>
and subject line Re: bug#43598: replace-in-string: finishing touches
has caused the debbugs.gnu.org bug report #43598,
regarding replace-in-string: finishing touches
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
43598: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=43598
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: replace-in-string: finishing touches Date: Thu, 24 Sep 2020 22:52:06 +0200
The new replace-in-string function is welcome but needs a few tweaks before we 
can call it done:

1. It doesn't quite work correctly with raw bytes:

  (replace-in-string "\377" "x" "a\377b")
  => "axb"
  (replace-in-string "\377" "x" "a\377ø")
  => "a\377ø"

The easiest solution is to reimplement it in terms of replace-regexp-in-string 
for now, and optimise it later (although I feel a bit bad undoing Lars's pretty 
handiwork...)

We have messy semantics here, because string-equal does not equate "\377" and 
(string-to-multibyte "\377"), but string-match-p does...

2. It is documented always to return a new string, but that's a tad 
over-generous nowadays; very few string functions do that. If we drop that 
guarantee, we get some optimisation opportunities:

- it can return the input string itself if no matches were found (a fairly 
common case)
- it can be marked pure, not just side-effect-free, so that the byte compiler 
can constant-propagate through calls to it

3. The name is somewhat unfortunate since a function by that name in XEmacs 
uses regexp matching.
In fact, the new function probably broke prolog-mode because of that (see 
prolog-replace-in-string).
While we can fix prolog-mode, we can't easily fix code outside the Emacs tree 
that may have similar problems.

Perhaps we should rename it to string-replace, in line with the modern naming 
convention discussed some time ago.




--- End Message ---
--- Begin Message --- Subject: Re: bug#43598: replace-in-string: finishing touches Date: Sun, 27 Sep 2020 18:14:36 +0200
27 sep. 2020 kl. 14.02 skrev Lars Ingebrigtsen <larsi@gnus.org>:

> Please go ahead and apply.

Applied, thank you.

Looks like we are done now. string-replace seems to be substantially faster 
than replace-regexp-in-string.
Good job!



--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]