mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-11 16:23:09 +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 = {};
|
var compileCache = {};
|
||||||
function expressionCompile(exp){
|
function expressionCompile(exp){
|
||||||
if (isFunction(exp)) return exp;
|
if (typeof exp === 'function') return exp;
|
||||||
var fn = compileCache[exp];
|
var fn = compileCache[exp];
|
||||||
if (!fn) {
|
if (!fn) {
|
||||||
var parser = new Parser(exp);
|
var parser = new Parser(exp);
|
||||||
|
|
@ -130,22 +130,28 @@ function createScope(parent, services, existing) {
|
||||||
$set: bind(instance, setter, instance),
|
$set: bind(instance, setter, instance),
|
||||||
|
|
||||||
$eval: function $eval(exp) {
|
$eval: function $eval(exp) {
|
||||||
if (exp !== undefined) {
|
if (exp === undefined) {
|
||||||
return expressionCompile(exp).call(instance);
|
|
||||||
} else {
|
|
||||||
for ( var i = 0, iSize = evalLists.sorted.length; i < iSize; i++) {
|
for ( var i = 0, iSize = evalLists.sorted.length; i < iSize; i++) {
|
||||||
for ( var queue = evalLists.sorted[i],
|
for ( var queue = evalLists.sorted[i],
|
||||||
jSize = queue.length,
|
jSize = queue.length,
|
||||||
j= 0; j < jSize; j++) {
|
j= 0; j < jSize; j++) {
|
||||||
instance.$tryEval(queue[j].fn, queue[j].handler);
|
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) {
|
$tryEval: function (expression, exceptionHandler) {
|
||||||
try {
|
try {
|
||||||
return expressionCompile(expression).call(instance);
|
if (typeof expression == 'function') {
|
||||||
|
return expression.call(instance);
|
||||||
|
} else {
|
||||||
|
return expressionCompile(expression).call(instance);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
(instance.$log || {error:error}).error(e);
|
(instance.$log || {error:error}).error(e);
|
||||||
if (isFunction(exceptionHandler)) {
|
if (isFunction(exceptionHandler)) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue