diff options
| author | Igor Minar | 2013-02-04 08:56:51 -0800 |
|---|---|---|
| committer | Igor Minar | 2013-02-11 14:07:10 -0800 |
| commit | a5b3bcf41cb0e3130439666a78a0ba9feadbd84a (patch) | |
| tree | 1cb2cf70f76ddc29c657adb75479113051e0d77c | |
| parent | 8801d9c2865ae74db4f4ce755764a9f46c49c9f8 (diff) | |
| download | angular.js-a5b3bcf41cb0e3130439666a78a0ba9feadbd84a.tar.bz2 | |
refactor(angular.copy): use slice(0) to clone arrays
slice(0) is way faster on most browsers
| -rw-r--r-- | src/Angular.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Angular.js b/src/Angular.js index 4685dbde..d983fd19 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -556,7 +556,8 @@ function copy(source, destination){ destination = source; if (source) { if (isArray(source)) { - destination = copy(source, []); + // http://jsperf.com/copy-array-with-slice-vs-for + destination = source.slice(0); } else if (isDate(source)) { destination = new Date(source.getTime()); } else if (isObject(source)) { |
