From a2595d5107f534b7e851d90302383d0a0d221c76 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 11 Aug 2014 21:43:53 -0700 Subject: [PATCH] Remove native `String#contains` use in `_.contains`. --- lodash.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lodash.js b/lodash.js index cf9e4eb16..d1365e96d 100644 --- a/lodash.js +++ b/lodash.js @@ -719,8 +719,7 @@ }()); /* Native method references for those with the same name as other `lodash` methods */ - var nativeContains = isNative(nativeContains = stringProto.contains) && nativeContains, - nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, + var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, nativeIsFinite = context.isFinite, nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys, @@ -4627,15 +4626,9 @@ } else { fromIndex = 0; } - if (typeof collection == 'string' || !isArray(collection) && isString(collection)) { - if (fromIndex >= length) { - return false; - } - return nativeContains - ? nativeContains.call(collection, target, fromIndex) - : collection.indexOf(target, fromIndex) > -1; - } - return getIndexOf(collection, target, fromIndex) > -1; + return (typeof collection == 'string' || !isArray(collection) && isString(collection)) + ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1) + : (getIndexOf(collection, target, fromIndex) > -1); } /**