Update _.assign and _.assignIn fast paths.

This commit is contained in:
John-David Dalton
2016-02-23 08:17:55 -08:00
parent dfe77571fb
commit 54294f15ef

View File

@@ -10843,6 +10843,10 @@
* // => { 'a': 1, 'c': 3, 'e': 5 }
*/
var assign = createAssigner(function(object, source) {
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
copyObject(source, keys(source), object);
return;
}
for (var key in source) {
if (hasOwnProperty.call(source, key)) {
assignValue(object, key, source[key]);
@@ -10850,13 +10854,6 @@
}
});
// Slow path for IE < 9.
if (nonEnumShadows) {
assign = createAssigner(function(object, source) {
copyObject(source, keys(source), object);
});
}
/**
* This method is like `_.assign` except that it iterates over own and
* inherited source properties.
@@ -10887,18 +10884,15 @@
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
*/
var assignIn = createAssigner(function(object, source) {
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
copyObject(source, keysIn(source), object);
return;
}
for (var key in source) {
assignValue(object, key, source[key]);
}
});
// Slow path for IE < 9.
if (nonEnumShadows) {
assignIn = createAssigner(function(object, source) {
copyObject(source, keysIn(source), object);
});
}
/**
* This method is like `_.assignIn` except that it accepts `customizer` which
* is invoked to produce the assigned values. If `customizer` returns `undefined`