Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily

From: Mattias Engdegård <[email-masked]>
Date: Sun, 3 Dec 2023 11:43:07 +0100

2 dec. 2023 kl. 20.26 skrev Raffael Stocker <[email-masked]>:

> Is this the case? As ‘mapc’ is implemented directly in C and ‘dolist’
> falls back to ‘while’, I thought it would be the other way around.

It's the function calls that are expensive. `dolist` just expands to a loop.
It's even worse if the lambda expression accesses variables outside (which wasn't the case here) because that forces creation of a closure.

> However, I checked your proposed version and there is an issue with
> replacement of sub- and superscripts.

Look at that, I got the semantics wrong. Sorry about that. Here's a new patch.
A lot less pretty this time.

In any case, make sure to include unit tests in your final patch.

The whole problem is compounded by the public variables (math-read-replacement-list etc) that we somehow feel a need to keep unchanged just in case some user modifies them, despite this almost certainly never happens.