[idea] escapeTextForBrowser, test string for unsafe chars before escaping#1863
Closed
syranide wants to merge 1 commit intofacebook:masterfrom
syranide:escapetest
Closed
[idea] escapeTextForBrowser, test string for unsafe chars before escaping#1863syranide wants to merge 1 commit intofacebook:masterfrom syranide:escapetest
syranide wants to merge 1 commit intofacebook:masterfrom
syranide:escapetest
Conversation
Collaborator
|
Going to close this, let's reopen if escapeTextForBrowser is actually a bottleneck. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
http://jsperf.com/escapeindexo/2 (short strings), http://jsperf.com/escapeindexo/3 (long strings)
Rough performance figures in IE8 and Chrome:
Testing and not escaping results in +100-200% (short), +30-70% (long)
Testing and escaping results in -33% (short and long)
Performance gained by this PR naturally increases for shorter strings and decrease for longer strings, considering that most of the attributes (style being the exception) generally have very short strings, this is good.
I would think that (far) more than half of the strings we pass through that function don't need to be escaped, meaning this should result in a performance improvement.
Also changed
ESCAPE_LOOKUPto use single quotes while I was at it (feel free to object :)).I'm not convinced that we should take it, posting this to share my results.