mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Simplify createCache bailout.
Former-commit-id: 2d72da41abfd2bf83017534d841444d99b47776b
This commit is contained in:
15
lodash.js
15
lodash.js
@@ -220,9 +220,7 @@
|
|||||||
typeCache = cache[type] || (cache[type] = {});
|
typeCache = cache[type] || (cache[type] = {});
|
||||||
|
|
||||||
if (type == 'object') {
|
if (type == 'object') {
|
||||||
if ((typeCache[key] || (typeCache[key] = [])).push(value) == this.array.length) {
|
(typeCache[key] || (typeCache[key] = [])).push(value);
|
||||||
cache[type] = false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
typeCache[key] = true;
|
typeCache[key] = true;
|
||||||
}
|
}
|
||||||
@@ -279,8 +277,13 @@
|
|||||||
*/
|
*/
|
||||||
function createCache(array) {
|
function createCache(array) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = array.length;
|
length = array.length,
|
||||||
|
first = array[0],
|
||||||
|
last = array[length - 1];
|
||||||
|
|
||||||
|
if (first && typeof first == 'object' && last && typeof last == 'object') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var cache = getObject();
|
var cache = getObject();
|
||||||
cache['false'] = cache['null'] = cache['true'] = cache['undefined'] = false;
|
cache['false'] = cache['null'] = cache['true'] = cache['undefined'] = false;
|
||||||
|
|
||||||
@@ -292,9 +295,7 @@
|
|||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
result.push(array[index]);
|
result.push(array[index]);
|
||||||
}
|
}
|
||||||
return cache.object === false
|
return result;
|
||||||
? (releaseObject(result), null)
|
|
||||||
: result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user