-
Notifications
You must be signed in to change notification settings - Fork 3
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
Avoid O(N) string allocations in escapeContent #18
Comments
@InPermutation I had some time this morning, and I think my fix in version 3.2.25 should improve the performance of |
Looks like it will be much faster to me, though I haven't
|
Ok cool I re-opened the issue and will look into these! |
@InPermutation please take a look at version 3.3.0 which should provide an even more optimized solution. I also added a follow up fix in 3.3.1. The main challenge with
You were right about the bug; it did escape all leading spaces in values. Fortunately, it didn't necessarily cause a problem because they would just be converted back to normal spaces. With the latest changes, it should now escape only the first leading space in values. The regular expression should also be optimized based on the I'm fairly confident about closing this issue, but please let me know if you spot anything I might have missed! |
Like in #16,
escapeContent
is rebuilding the entire input string character-by-character, and can be greatly optimized by using a single.replace(/RegExp/g)
.The text was updated successfully, but these errors were encountered: