]> git.eshelyaron.com Git - emacs.git/commit
Calc: speed up math-read-preprocess-string (bug#67536)
authorMattias EngdegÄrd <mattiase@acm.org>
Tue, 19 Dec 2023 16:10:42 +0000 (17:10 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 21 Dec 2023 20:53:59 +0000 (21:53 +0100)
commit10fff0281a61cdb9c4833aced0ebc7f1fca839a3
treed43d0b3fd8be595b50b66bea5b62397e559ec537
parent2e6d132cb32c344e8c9c2ce6703db2e5ea8bbc82
Calc: speed up math-read-preprocess-string (bug#67536)

`math-read-preprocess-string` is one of the bottlenecks of `calc-eval`
and was unnecessarily slow even with no substitutions made.
This affected org-mode in particular, where `calc-eval` is called
repeatedly to recalculate tables.

Reported by Raffael Stocker who also wrote the unit tests here.

* lisp/calc/calc-aent.el (math--read-preprocess-re-cache): New.
(math-read-preprocess-string):
Use math--read-preprocess-re-cache, first computing it if necessary.
* test/lisp/calc/calc-tests.el (calc-math-read-preprocess-string):
New test.

(cherry picked from commit 7c1c2519167d51931a5d17f27529c8c8358c7c61)
lisp/calc/calc-aent.el
test/lisp/calc/calc-tests.el