Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Cache expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelw committed Aug 22, 2013
1 parent ea5da4d commit d87b95b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/polymer-expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,17 @@
return binding;
}

// TODO(rafaelw): Implement simple LRU.
var expressionParseCache = {};

function getExpressionBinding(model, expressionText) {
try {
// TODO(rafaelw): Cache expressions.
var delegate = new ASTDelegate();
esprima.parse(expressionText, delegate);
var delegate = expressionParseCache[expressionText];
if (!delegate) {
delegate = new ASTDelegate();
esprima.parse(expressionText, delegate);
expressionParseCache[expressionText] = delegate;
}

if (!delegate.expression && !delegate.labeledStatements.length)
return;
Expand Down

0 comments on commit d87b95b

Please sign in to comment.