Optimize Base#merge() to not use Base#each()

This commit is contained in:
Jürg Lehni 2013-11-24 15:03:51 +01:00
parent f7a473a598
commit 42ec121c0a

View file

@ -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;
},
/**