[type1] Directly search for eexec in private dict

System Internals / FreeType - Ben Wagner [chromium.org] - 16 June 2022 14:51 UTC

This code originally just searched for `eexec`. This was later modified to check that the `eexec` found is valid (not in a string or comment). This was done by searching for `eexec` as before and then, for each `eexec` found, searching from the beginning using the correct parsing to see if the `eexec` was still found. If the private dictionary is large and contains many copies of `eexec` which are not valid, the initial part of the private dictionary is scanned once for each, potentially leading to n^2 parsing time.

Instead of finding an initial `eexec` and then re-parsing to discover if it is valid, drop the initial search for `eexec` and just parse to find a valid `eexec`. This is strictly faster since the validation must happen anyway and avoids restarting from the beginning each time an `eexec` is found in the data.

- src/type1/t1parse.c (T1_Get_Private_Dict): avoid n^2 parsing

Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1328883

907952100 [type1] Directly search for eexec in private dict
src/type1/t1parse.c | 55 +++++++++--------------------------------------------
1 file changed, 9 insertions(+), 46 deletions(-)

Upstream: git.savannah.gnu.org


  • Share