Replace name and entity regular expressions with specific functions for ~15% performance improvement #216
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
Regular expressions are generally fast and become increasingly more efficient with longer strings.
However this module tests character-by-character, so extracting the character code and using equality and range checks greatly increases the performance of element and entity name detection.
Using the node-expat benchmark tests reveals this gain is around 15%.
sax v1.2.4:
with this change:
The existing test suite continues to pass after this change.
This is the third and most likely final performance improvement I'm going to be able to make to sax, at least in the short term. When this change is viewed with #204 and #208 it appears we've been able to improve performance by at least a factor of 3x since v1.2.1.
Once again thank you for all your time maintaining this highly depended upon module.