mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Avoid inspecting the entire key-value array when adding values to a stack.
This commit is contained in:
@@ -2122,8 +2122,13 @@
|
|||||||
*/
|
*/
|
||||||
function stackSet(key, value) {
|
function stackSet(key, value) {
|
||||||
var cache = this.__data__;
|
var cache = this.__data__;
|
||||||
if (Map && cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
|
if (cache instanceof ListCache) {
|
||||||
cache = this.__data__ = new MapCache(cache.__data__);
|
var pairs = cache.__data__;
|
||||||
|
if (!Map || pairs.length < LARGE_ARRAY_SIZE) {
|
||||||
|
pairs.push([key, value]);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
cache = this.__data__ = new MapCache(pairs);
|
||||||
}
|
}
|
||||||
cache.set(key, value);
|
cache.set(key, value);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
Reference in New Issue
Block a user