-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Don't allocate the sticky regex source when the resulting regexp is already cached #154
Conversation
src/xregexp.js
Outdated
@@ -839,7 +839,7 @@ XRegExp.exec = function(str, regex, pos, sticky) { | |||
regex[REGEX_DATA][cacheKey] = copyRegex(regex, { | |||
addG: true, | |||
addY: addY, | |||
source: sourceY, | |||
source: fakeY? regex.source + '|()' : void 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits: Space before ?
, and please just use undefined
rather than void 0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, updating
Thinking more about this, I'm not sure what to do for regexps that are both global and sticky. It makes little sense to set both flags, but it is legal AFAIK... Scaling down. |
…ed expression is already cached
To be clear, the "fast sticky polyfill" rev is just avoiding an unnecessary string concat in some cases, and otherwise not changing behavior at all, correct? |
Correct. I've removed the lastIndex thing, I'll make another PR once the |
Thanks--perfect! Removing it from this PR made me more confident to merge the other change. BTW, the reason XRegExp isn't yet fully tackling |
@pygy BTW, if you submit robust |
Ok, According to both the latest draft and the ES6 spec, |
As discussed previously in #152 and #153