mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 06:00:56 -05:00
Optimize Base#merge() to not use Base#each()
This commit is contained in:
parent
f7a473a598
commit
42ec121c0a
1 changed files with 9 additions and 6 deletions
|
@ -484,14 +484,17 @@ Base.inject(/** @lends Base# */{
|
|||
},
|
||||
|
||||
/**
|
||||
* Merge all passed hash objects into a newly creted Base object.
|
||||
* Merge all passed plain objects into a newly creted Base object.
|
||||
*/
|
||||
merge: function() {
|
||||
return Base.each(arguments, function(hash) {
|
||||
Base.each(hash, function(value, key) {
|
||||
this[key] = value;
|
||||
}, this);
|
||||
}, new Base(), true); // Pass true for asArray, as arguments is none
|
||||
var res = new Base();
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
var obj = arguments[i];
|
||||
for (var j in obj)
|
||||
if (obj.hasOwnProperty(j))
|
||||
res[j] = obj[j];
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue