From cb29632a5802e930262919b3db64ca4806c5cfc7 Mon Sep 17 00:00:00 2001 From: Karl Seamon Date: Tue, 17 Dec 2013 14:22:04 -0500 Subject: perf: use faster check for $$ prefix Use two calls to charAt instead of substr to detect a $$prefix in the shallowCopy functions. This makes shallowCopy 25-50% faster (depending on which browser is used). http://jsperf.com/angular-shallow-copy Closes #5457 --- src/ngResource/resource.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ngResource') diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index 281dd4ac..a007c7b1 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -35,7 +35,7 @@ function shallowClearAndCopy(src, dst) { }); for (var key in src) { - if (src.hasOwnProperty(key) && key.substr(0, 2) !== '$$') { + if (src.hasOwnProperty(key) && key.charAt(0) !== '$' && key.charAt(1) !== '$') { dst[key] = src[key]; } } -- cgit v1.2.3