From f2f57dc5a5b8e6cfecf62b0ac343d098522751cf Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 6 Mar 2014 00:45:01 -0800 Subject: [PATCH] Deopt `_.invoke`. --- lodash.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lodash.js b/lodash.js index 842366270..36f20e33b 100644 --- a/lodash.js +++ b/lodash.js @@ -4147,22 +4147,15 @@ * // => [['1', '2', '3'], ['4', '5', '6']] */ function invoke(collection, methodName) { - var index = -1, + var args = slice(arguments, 2), + index = -1, isFunc = typeof methodName == 'function', length = collection ? collection.length : 0, result = Array(typeof length == 'number' ? length : 0); - if (arguments.length < 3 && isArray(collection)) { - while (++index < length) { - var value = collection[index]; - result[index] = isFunc ? methodName.call(value) : value[methodName](); - } - } else { - var args = slice(arguments, 2); - baseEach(collection, function(value) { - result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args); - }); - } + baseEach(collection, function(value) { + result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args); + }); return result; }