mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-18 15:50:22 +00:00
minor speed improvements
This commit is contained in:
parent
94759f4c2c
commit
a161a99ff8
1 changed files with 13 additions and 7 deletions
20
src/Scope.js
20
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)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue