]> git.eshelyaron.com Git - emacs.git/commit
Avoid resizing mutation in subst-char-in-string, take two
authorMattias EngdegÄrd <mattiase@acm.org>
Mon, 13 May 2024 08:44:05 +0000 (10:44 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 16 May 2024 08:18:41 +0000 (10:18 +0200)
commit0526e4f63b92e4225488a0558120c5a2536d6c5e
treef5f5f7a96b3dceb546f293abeb11023c17c2c896
parent7c6682ee2b988f93ac95fd95aec57329c21f41c1
Avoid resizing mutation in subst-char-in-string, take two

This time we take care to preserve properties, and add a test.

* lisp/subr.el (subst-char-in-string):
Use string-replace to avoid resizing mutation and O(n^2) time.
* test/lisp/subr-tests.el (subr--subst-char-in-string): New test.

(cherry picked from commit 49e243c0c85d18fc775970d9ebd846eba3a6866e)
lisp/subr.el
test/lisp/subr-tests.el