mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-04 13:14:49 +00:00
performance improvement of single statement in parser
This commit is contained in:
parent
cc9f1fdf38
commit
20ce797906
1 changed files with 13 additions and 9 deletions
|
|
@ -325,15 +325,19 @@ function parser(text, json){
|
||||||
if (tokens.length > 0 && !peek('}', ')', ';', ']'))
|
if (tokens.length > 0 && !peek('}', ')', ';', ']'))
|
||||||
statements.push(filterChain());
|
statements.push(filterChain());
|
||||||
if (!expect(';')) {
|
if (!expect(';')) {
|
||||||
return function (self){
|
// optimize for the common case where there is only one statement.
|
||||||
var value;
|
// TODO(size): maybe we should not support multiple statements?
|
||||||
for ( var i = 0; i < statements.length; i++) {
|
return statements.length == 1
|
||||||
var statement = statements[i];
|
? statements[0]
|
||||||
if (statement)
|
: function (self){
|
||||||
value = statement(self);
|
var value;
|
||||||
}
|
for ( var i = 0; i < statements.length; i++) {
|
||||||
return value;
|
var statement = statements[i];
|
||||||
};
|
if (statement)
|
||||||
|
value = statement(self);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue