-
Notifications
You must be signed in to change notification settings - Fork 27.4k
refactor($parse): Create idents lazily #9229
Conversation
were you actually able to reproduce the issues they were talking about? |
@caitp This is what I did:
// parse.js@934
We were generating a function where code === 'if(s == null) return undefined;
s=((l&&l.hasOwnProperty("in"))?l:s).in;
return s;'
(we were creating one for |
6890ceb
to
3bd2eb4
Compare
Create the ident functions lazily as these are not used for filters not object literal properties Closes angular#9131
3bd2eb4
to
0fe9408
Compare
@@ -426,7 +430,7 @@ Parser.prototype = { | |||
primary = this.object(); | |||
} else { | |||
var token = this.expect(); | |||
primary = token.fn; | |||
primary = token.fn || token.lazyFn && token.lazyFn(); |
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.
Could this line change to
primary = CONSTANTS[token.text] || getterFn(token.text, this.options, this.text);
...and avoid the lazyFn
+ fn
setup above?
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.
a primary can be an identifier or a constant, so it would look like something like this
primary = token.fn || token.identifier && (CONSTANTS[token.text] || getterFn(token.text, this.options, token.expression));
where expression
and identifier
need to be added
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.
The expression text already exists (this.text in Parser), I guess the identifier
flag and token.fn ||
would be needed though.
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.
you are right, we already have expression
cad9560
to
f294244
Compare
closing this in favor of #9431 |
Create the ident functions lazily as these are not used for filters not object literal properties
The generated functions that are not used can cause issues with some browsers
Closes #9131
Note: This may have cause some performance improvements