remove the uneeded call to createScope when evaluating expressions

This commit is contained in:
Misko Hevery 2010-05-30 15:45:33 -07:00
parent fa0702bad1
commit 0e88e35e5c
3 changed files with 37 additions and 4 deletions

32
scenario/perf.html Normal file
View file

@ -0,0 +1,32 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script type="text/javascript" src="../src/angular-bootstrap.js#autobind"></script>
<script type="text/javascript">
function PerfCntl(){}
PerfCntl.prototype = {
createItems: function(){
var items = [];
for ( var i = 0; i < 100; i++) {
var item = {
name: "" + Math.random(),
parts: [Math.random(), Math.random()]
};
items.push(item);
}
return items;
}
};
</script>
</head>
<body ng:init="$window.$scope = this; items = createItems()" ng-controller="PerfCntl">
<input type="text" name="text"/>
<hr/>
<ul>
<li ng-repeat="item in items.$filter('').$orderBy('name')">
{{item.name}} {{item.parts.join(', ')}}
</li>
</ul>
</body>
</html>

View file

@ -60,11 +60,12 @@ function expressionCompile(exp){
// TODO(remove this hack)
function parserNewScopeAdapter(fn) {
return function(){
var self = this;
return fn({
state: this,
state: self,
scope: {
set: this.$set,
get: this.$get
set: function(key, value){ return setter(self, key, value);},
get: function(key) { return getter(self, key); }
}
});
};

View file

@ -297,7 +297,7 @@ var angularFunction = {
return expression;
} else if (expression){
return function($) {
return createScope($).$eval(expression);
return expressionCompile(expression).apply($);
};
} else {
return identity;