Skip to content

Don't re-compile RegExp in clone() #37

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

Merged
merged 3 commits into from
Mar 18, 2017
Merged

Don't re-compile RegExp in clone() #37

merged 3 commits into from
Mar 18, 2017

Conversation

tjvr
Copy link
Collaborator

@tjvr tjvr commented Mar 18, 2017

As mentioned in #36

This has minimal effect on performance.

This has minimal effect on performance.
@tjvr tjvr changed the title Rewrite clone() to not re-compile RegExp Don't re-compile RegExp in clone() Mar 18, 2017
moo.js Outdated
@@ -437,7 +432,7 @@
var s = this.states[key]
map[key] = {
groups: s.groups,
regexp: new RegExp(s.regexp.source, s.regexp.flags),
regexp: s.regexp,
error: s.error,
}
}
Copy link
Collaborator

@nathan nathan Mar 18, 2017

Choose a reason for hiding this comment

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

I think you should actually be able to get rid of all the state-map copying code here, and just hand this.states to the new Lexer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. Nice! :-)

@nathan nathan merged commit b79f44f into master Mar 18, 2017
@nathan nathan deleted the clone branch March 18, 2017 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants