-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
for loops are now generated inline rather than in an IIFE #1983
Conversation
@@ -561,7 +562,8 @@ Lexer.prototype = { | |||
if (captures = /^(?:- *)?(?:each|for) +([a-zA-Z_$][\w$]*)(?: *, *([a-zA-Z_$][\w$]*))? * in *([^\n]+)/.exec(this.input)) { | |||
this.consume(captures[0].length); | |||
var tok = this.tok('each', captures[1]); | |||
tok.key = captures[2] || '$index'; | |||
tok.key = captures[2] || '$$i' + this.eachCount; | |||
this.eachCount++; |
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.
this is split into two lines on purpose for readability
This is great, but definitely a breaking change. Could you make this pull request against jade-code-gen project as well. |
Moved variable name generation out of the lexer. |
Unfortunately I still don't consider this backwards compatible because:
I'm very excited for getting this done in the 2.0.0 release though :) |
Now that we have started landing breaking changes in master, can we merge this or should it go straight into jade-code-gen? |
It needs to go straight into jade-code-gen |
This again improves performance a little bit (part of #1975).
The first change is to rename
$index
to$$iN
, where N is the Nth for loop. The PR assumes this is safe. It also assumes it is safe to use variables that look likeKEY__obj
andKEY__l
, where KEY is either$$iN
or the KEY provided by the user.