diff options
| author | Misko Hevery | 2010-07-26 15:54:50 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-07-26 15:54:50 -0700 |
| commit | a161a99ff8adfdf91202768950c6cddc93bf3101 (patch) | |
| tree | cdf6231562ecea8f6aa18b2f1d6ea5442cddf6b4 /src/Scope.js | |
| parent | 94759f4c2cab91d35a18159a00fbdaec0af79aa9 (diff) | |
| download | angular.js-a161a99ff8adfdf91202768950c6cddc93bf3101.tar.bz2 | |
minor speed improvements
Diffstat (limited to 'src/Scope.js')
| -rw-r--r-- | src/Scope.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Scope.js b/src/Scope.js index 6b011936..4d2aa5c3 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -90,7 +90,7 @@ function getterFn(path){ var compileCache = {}; function expressionCompile(exp){ - if (isFunction(exp)) return exp; + if (typeof exp === 'function') return exp; var fn = compileCache[exp]; if (!fn) { var parser = new Parser(exp); @@ -130,22 +130,28 @@ function createScope(parent, services, existing) { $set: bind(instance, setter, instance), $eval: function $eval(exp) { - if (exp !== undefined) { - return expressionCompile(exp).call(instance); - } else { + if (exp === undefined) { for ( var i = 0, iSize = evalLists.sorted.length; i < iSize; i++) { for ( var queue = evalLists.sorted[i], - jSize = queue.length, - j= 0; j < jSize; j++) { + jSize = queue.length, + j= 0; j < jSize; j++) { instance.$tryEval(queue[j].fn, queue[j].handler); } } + } else if (typeof exp === 'function'){ + return exp.call(instance); + } else { + return expressionCompile(exp).call(instance); } }, $tryEval: function (expression, exceptionHandler) { try { - return expressionCompile(expression).call(instance); + if (typeof expression == 'function') { + return expression.call(instance); + } else { + return expressionCompile(expression).call(instance); + } } catch (e) { (instance.$log || {error:error}).error(e); if (isFunction(exceptionHandler)) { |
