From a5b3bcf41cb0e3130439666a78a0ba9feadbd84a Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 4 Feb 2013 08:56:51 -0800 Subject: refactor(angular.copy): use slice(0) to clone arrays slice(0) is way faster on most browsers --- src/Angular.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Angular.js') 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)) { -- cgit v1.2.3