Memoize stringToPath.

This commit is contained in:
John-David Dalton
2016-03-03 15:58:23 -08:00
parent cf74ebeb71
commit e4b3cde0a4

View File

@@ -1622,6 +1622,13 @@
}
};
// Ensure wrappers are instances of `baseLodash`.
lodash.prototype = baseLodash.prototype;
lodash.prototype.constructor = lodash;
LodashWrapper.prototype = baseCreate(baseLodash.prototype);
LodashWrapper.prototype.constructor = LodashWrapper;
/*------------------------------------------------------------------------*/
/**
@@ -1738,6 +1745,10 @@
return result;
}
// Ensure `LazyWrapper` is an instance of `baseLodash`.
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
LazyWrapper.prototype.constructor = LazyWrapper;
/*------------------------------------------------------------------------*/
/**
@@ -1801,6 +1812,9 @@
hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
}
// Avoid inheriting from `Object.prototype` when possible.
Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto;
/*------------------------------------------------------------------------*/
/**
@@ -1909,6 +1923,13 @@
return this;
}
// Add methods to `MapCache`.
MapCache.prototype.clear = mapClear;
MapCache.prototype['delete'] = mapDelete;
MapCache.prototype.get = mapGet;
MapCache.prototype.has = mapHas;
MapCache.prototype.set = mapSet;
/*------------------------------------------------------------------------*/
/**
@@ -1969,6 +1990,9 @@
}
}
// Add methods to `SetCache`.
SetCache.prototype.push = cachePush;
/*------------------------------------------------------------------------*/
/**
@@ -2077,6 +2101,13 @@
return this;
}
// Add methods to `Stack`.
Stack.prototype.clear = stackClear;
Stack.prototype['delete'] = stackDelete;
Stack.prototype.get = stackGet;
Stack.prototype.has = stackHas;
Stack.prototype.set = stackSet;
/*------------------------------------------------------------------------*/
/**
@@ -5462,13 +5493,13 @@
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
function stringToPath(string) {
var stringToPath = memoize(function(string) {
var result = [];
toString(string).replace(rePropName, function(match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
});
return result;
}
});
/**
* Creates a clone of `wrapper`.
@@ -9111,10 +9142,13 @@
memoized.cache = cache.set(key, result);
return result;
};
memoized.cache = new memoize.Cache;
memoized.cache = new (memoize.Cache || MapCache);
return memoized;
}
// Assign cache to `_.memoize`.
memoize.Cache = MapCache;
/**
* Creates a function that negates the result of the predicate `func`. The
* `func` predicate is invoked with the `this` binding and arguments of the
@@ -14750,40 +14784,7 @@
/*------------------------------------------------------------------------*/
// Ensure wrappers are instances of `baseLodash`.
lodash.prototype = baseLodash.prototype;
lodash.prototype.constructor = lodash;
LodashWrapper.prototype = baseCreate(baseLodash.prototype);
LodashWrapper.prototype.constructor = LodashWrapper;
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
LazyWrapper.prototype.constructor = LazyWrapper;
// Avoid inheriting from `Object.prototype` when possible.
Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto;
// Add functions to the `MapCache`.
MapCache.prototype.clear = mapClear;
MapCache.prototype['delete'] = mapDelete;
MapCache.prototype.get = mapGet;
MapCache.prototype.has = mapHas;
MapCache.prototype.set = mapSet;
// Add functions to the `SetCache`.
SetCache.prototype.push = cachePush;
// Add functions to the `Stack` cache.
Stack.prototype.clear = stackClear;
Stack.prototype['delete'] = stackDelete;
Stack.prototype.get = stackGet;
Stack.prototype.has = stackHas;
Stack.prototype.set = stackSet;
// Assign cache to `_.memoize`.
memoize.Cache = MapCache;
// Add functions that return wrapped values when chaining.
// Add methods that return wrapped values when chaining.
lodash.after = after;
lodash.ary = ary;
lodash.assign = assign;
@@ -14936,12 +14937,12 @@
lodash.extend = assignIn;
lodash.extendWith = assignInWith;
// Add functions to `lodash.prototype`.
// Add methods to `lodash.prototype`.
mixin(lodash, lodash);
/*------------------------------------------------------------------------*/
// Add functions that return unwrapped values when chaining.
// Add methods that return unwrapped values when chaining.
lodash.add = add;
lodash.attempt = attempt;
lodash.camelCase = camelCase;
@@ -15304,7 +15305,7 @@
'func': undefined
}];
// Add functions to the lazy wrapper.
// Add methods to `LazyWrapper`.
LazyWrapper.prototype.clone = lazyClone;
LazyWrapper.prototype.reverse = lazyReverse;
LazyWrapper.prototype.value = lazyValue;