revert: refactor($parse): only instantiate lex/parse once

This reverts commit 281feba4ca.

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.
This commit is contained in:
Igor Minar 2013-10-07 11:10:24 -07:00
parent 7a586e5c19
commit 670cd9c165

View file

@ -1043,8 +1043,6 @@ function $ParseProvider() {
var cache = {};
this.$get = ['$filter', '$sniffer', function($filter, $sniffer) {
return function(exp) {
var lexer = new Lexer($sniffer.csp);
var parser = new Parser(lexer, $filter, $sniffer.csp);
var parsedExpression;
switch (typeof exp) {
@ -1053,6 +1051,8 @@ function $ParseProvider() {
return cache[exp];
}
var lexer = new Lexer($sniffer.csp);
var parser = new Parser(lexer, $filter, $sniffer.csp);
parsedExpression = parser.parse(exp, false);
if (exp !== 'hasOwnProperty') {