From 54294f15ef9647b5f2582b2401fc4fd87d0e49e1 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 23 Feb 2016 08:17:55 -0800 Subject: [PATCH] Update `_.assign` and `_.assignIn` fast paths. --- lodash.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/lodash.js b/lodash.js index 8a86e46c2..64262f9a8 100644 --- a/lodash.js +++ b/lodash.js @@ -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`