Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Parser pattern size to be parametrizable #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mbenedettini
Copy link

When parsing files with big strings allowing a big pattern size can help shave off precious milliseconds making parsing considerably faster since less loops of the parser are needed, leaving the big lift to the Javascript Regexp engine.

numberFraction: /^[\.eE]/,
numberExponent: /^[eE]/,
numberExpSign: /^[-+]/
};
const MAX_PATTERN_SIZE = 16;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this const name is now confusing (compared to DEFAULT_PATTERN_SIZE) but I couldn't find a better name

@uhop uhop self-assigned this Jun 25, 2024
@uhop
Copy link
Owner

uhop commented Jun 25, 2024

@mbenedettini do you have any benchmarks showing that the speed of parsing had improved?

I am asking because /.{1,256}/ comes with a penalty for regular expression engines. For example it is less effective
than /.?/, /.*/ or /.+/, especially when the upper number is high. TBH, I had worried that {,256} is too high and
should be reduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants