diff options
| author | Misko Hevery | 2010-05-30 20:21:40 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-05-30 20:21:40 -0700 |
| commit | 81dac70e72430b7ab9a824ab923038c1e00e7003 (patch) | |
| tree | 17efcdc2df48d32a0a928cc2ab755f355e9f6ae1 /src | |
| parent | 2e33e89a77d115ff17f5841ec328b1c1e4228161 (diff) | |
| download | angular.js-81dac70e72430b7ab9a824ab923038c1e00e7003.tar.bz2 | |
imrove $orderBy performance
Diffstat (limited to 'src')
| -rw-r--r-- | src/Angular.js | 13 | ||||
| -rw-r--r-- | src/apis.js | 4 |
2 files changed, 9 insertions, 8 deletions
diff --git a/src/Angular.js b/src/Angular.js index 39e9b385..2b26c88d 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -244,18 +244,17 @@ function copy(source, destination){ while(destination.length) { destination.pop(); } + for ( var i = 0; i < source.length; i++) { + destination.push(copy(source[i])); + } } else { foreach(destination, function(value, key){ delete destination[key]; }); + for ( var key in source) { + destination[key] = copy(source[key]); + } } - foreach(source, function(value, key){ - destination[key] = value ? - ( isArray(value) ? - copy(value, []) : - (isObject(value) ? copy(value, {}) : value)) : - value; - }); return destination; } } diff --git a/src/apis.js b/src/apis.js index 0038a6e1..306d0ce8 100644 --- a/src/apis.js +++ b/src/apis.js @@ -190,7 +190,9 @@ var angularArray = { } return 0; }; - return copy(array).sort(reverse(comparator, descend)); + var arrayCopy = []; + for ( var i = 0; i < array.length; i++) { arrayCopy.push(array[i]); } + return arrayCopy.sort(reverse(comparator, descend)); }, 'orderByToggle':function(predicate, attribute) { var STRIP = /^([+|-])?(.*)/; |
