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

Commit

Permalink
revert: refactor($parse): only instantiate lex/parse once
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
IgorMinar committed Oct 7, 2013
1 parent 7a586e5 commit 670cd9c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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') {
Expand Down

0 comments on commit 670cd9c

Please sign in to comment.