aboutsummaryrefslogtreecommitdiffstats
path: root/src/Scope.js
diff options
context:
space:
mode:
authorMisko Hevery2010-07-26 15:54:50 -0700
committerMisko Hevery2010-07-26 15:54:50 -0700
commita161a99ff8adfdf91202768950c6cddc93bf3101 (patch)
treecdf6231562ecea8f6aa18b2f1d6ea5442cddf6b4 /src/Scope.js
parent94759f4c2cab91d35a18159a00fbdaec0af79aa9 (diff)
downloadangular.js-a161a99ff8adfdf91202768950c6cddc93bf3101.tar.bz2
minor speed improvements
Diffstat (limited to 'src/Scope.js')
-rw-r--r--src/Scope.js20
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)) {