tweecode / twine

UI for creating hypertext stories
http://twinery.org
656 stars 97 forks source link

Fix performance issue in Wikifier.parse #190

Open dmchurch opened 6 years ago

dmchurch commented 6 years ago

The Wikifier.textPrimitives.unquoted method of parsing quoted strings is very slow when dealing with long strings that look like variable names, since it has to test each initial substring to see if it qualifies as "unquoted". This fixes the problem by removing all quoted strings from the input before parsing and restoring them after all of the calls to alter().

This can be tested by calling another passage as a macro and passing a very long variable-looking name inside a string, for example;

<<SomePassage "$this_is_a_very_long_variable_name">>