MCPcopy Index your code
hub / github.com/stemkoski/stemkoski.github.com / createCache

Function createCache

MathBox/mathbox-bundle.js:35426–35449  ·  view source on GitHub ↗

* Creates a cache object to optimize linear searches of large arrays. * * @private * @param {Array} [array=[]] The array to search. * @returns {null|Object} Returns the cache object or `null` if caching should not be used.

(array)

Source from the content-addressed store, hash-verified

35424 * @returns {null|Object} Returns the cache object or `null` if caching should not be used.
35425 */
35426 function createCache(array) {
35427 var index = -1,
35428 length = array.length,
35429 first = array[0],
35430 mid = array[(length / 2) | 0],
35431 last = array[length - 1];
35432
35433 if (first && typeof first == 'object' &&
35434 mid && typeof mid == 'object' && last && typeof last == 'object') {
35435 return false;
35436 }
35437 var cache = getObject();
35438 cache['false'] = cache['null'] = cache['true'] = cache['undefined'] = false;
35439
35440 var result = getObject();
35441 result.array = array;
35442 result.cache = cache;
35443 result.push = cachePush;
35444
35445 while (++index < length) {
35446 result.push(array[index]);
35447 }
35448 return result;
35449 }
35450
35451 /**
35452 * Used by `template` to escape characters for inclusion in compiled

Callers 3

baseDifferenceFunction · 0.70
baseUniqFunction · 0.70
intersectionFunction · 0.70

Calls 1

getObjectFunction · 0.70

Tested by

no test coverage detected