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

Commit 670cd9c

Browse files
committed
revert: refactor($parse): only instantiate lex/parse once
This reverts commit 281feba. Since Lexer and Parser objects are stateful it is not safe to reuse them for parsing of multiple expressions. After recent refactoring into prototypical style, the instantiation of these objects is so cheap that it's not a huge win to use singletons here.
1 parent 7a586e5 commit 670cd9c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ng/parse.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,6 @@ function $ParseProvider() {
10431043
var cache = {};
10441044
this.$get = ['$filter', '$sniffer', function($filter, $sniffer) {
10451045
return function(exp) {
1046-
var lexer = new Lexer($sniffer.csp);
1047-
var parser = new Parser(lexer, $filter, $sniffer.csp);
10481046
var parsedExpression;
10491047

10501048
switch (typeof exp) {
@@ -1053,6 +1051,8 @@ function $ParseProvider() {
10531051
return cache[exp];
10541052
}
10551053

1054+
var lexer = new Lexer($sniffer.csp);
1055+
var parser = new Parser(lexer, $filter, $sniffer.csp);
10561056
parsedExpression = parser.parse(exp, false);
10571057

10581058
if (exp !== 'hasOwnProperty') {

0 commit comments

Comments
 (0)