From 59278a7a8539f638166d16374bdea0884bc0d15c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 9 Oct 2015 12:58:10 -0700 Subject: [PATCH] Reduce `baseExtremum`. --- lodash.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/lodash.js b/lodash.js index cef57e0f1..6e420a435 100644 --- a/lodash.js +++ b/lodash.js @@ -624,28 +624,19 @@ * @returns {*} Returns the extremum value. */ function baseExtremum(array, iteratee, comparator) { - var computed, - result, - index = -1, + var index = -1, length = array.length; while (++index < length) { var value = array[index], current = iteratee(value); - if (current === current && current != null) { - computed = current; - result = value; - break; - } - } - while (++index < length) { - var value = array[index], - current = iteratee(value); - - if (current != null && comparator(current, computed)) { - computed = current; - result = value; + if (current != null && (computed === undefined + ? current === current + : comparator(current, computed) + )) { + var computed = current, + result = value; } } return result;