diff options
| author | Vojta Jina | 2012-03-28 16:03:59 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-03-29 07:30:32 -0700 |
| commit | 6da355c3e1571b9a104fca2796df77a4194a28a2 (patch) | |
| tree | 8599843420c713b0a835e02311065fa984dcb1ee /src/Angular.js | |
| parent | f2106692b1ebf00aa5f8b2accd75f014b6cd4faa (diff) | |
| download | angular.js-6da355c3e1571b9a104fca2796df77a4194a28a2.tar.bz2 | |
refactor($compile): move methods of attr object into prototype
We have many instances of this object and we clone them as well (e.g. ng-repeat).
This should save some memory and performance as well.
Double prefixed private properties of attr object:
attr.$element -> attr.$$element
attr.$observers -> attr.$$observers
Update shallowCopy to not copy $$ properties and allow passing optional destination object.
Diffstat (limited to 'src/Angular.js')
| -rw-r--r-- | src/Angular.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Angular.js b/src/Angular.js index 0f66d99c..c0da2174 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -598,16 +598,16 @@ function copy(source, destination){ /** * Create a shallow copy of an object - * @param src */ -function shallowCopy(src) { - var dst = {}, - key; - for(key in src) { - if (src.hasOwnProperty(key)) { +function shallowCopy(src, dst) { + dst = dst || {}; + + for(var key in src) { + if (src.hasOwnProperty(key) && key.substr(0, 2) !== '$$') { dst[key] = src[key]; } } + return dst; } |
