Optimize text replacement
Text replacements is an alist of (SOURCE . DEST) strings that are applied (longest SOURCE first) to text strings. There is a predefined list of special chars in scm/text.scm, that defaults to off, but is used in Carver MSDM score.
Before this change, we'd walk the string, trying to find substrings of the input string against entries in the alist. For the standard special characters, we'd go over the alist (100 entries) 12 times (largest replacement source text was 12 characters), for each character of the input string.
Instead, precalculate a set hash tables (ordered by size) of C++ strings. This matches faster, avoids matching against texts of the wrong size, and cuts out the C++ => Scheme => C++ roundtrip which costs memory.
Hardcode the replacement of space characters with ' '.
1a6d4c958c - Optimize text replacement baseline 43319677 - Cache the name => index lookup in Open_type_font args [-I carver MSDM-reduced] mem delta: -5908.000000 (stddev 68.857340 147.585004 n=3) mem delta: -0.744906 % (53d9fdd5c8 is leaner) time delta: -4.620000 (stddev 0.221435 0.020817 n=3) time delta: -19.913793 % (53d9fdd5c8 is faster)