Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6890ceb

Browse files
committed
refactor($parse): Create idents lazily
Create the ident functions lazily as these are not used for filters not object literal properties Closes #9131
1 parent d8c8b2e commit 6890ceb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/ng/parse.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ Lexer.prototype = {
318318
this.tokens.push({
319319
index: start,
320320
text: ident,
321-
fn: CONSTANTS[ident] || getterFn(ident, this.options, expression)
321+
fn: CONSTANTS[ident],
322+
lazyFn: CONSTANTS[ident] ? undefined : lazyGetterFn(ident, this.options, expression)
322323
});
323324

324325
if (methodName) {
@@ -426,7 +427,7 @@ Parser.prototype = {
426427
primary = this.object();
427428
} else {
428429
var token = this.expect();
429-
primary = token.fn;
430+
primary = token.fn || token.lazyFn && token.lazyFn();
430431
if (!primary) {
431432
this.throwError('not a primary expression', token);
432433
}
@@ -945,6 +946,12 @@ function getterFn(path, options, fullExp) {
945946
return fn;
946947
}
947948

949+
function lazyGetterFn(ident, options, expression) {
950+
return function() {
951+
return getterFn(ident, options, expression);
952+
};
953+
}
954+
948955
///////////////////////////////////
949956

950957
/**

0 commit comments

Comments
 (0)