Skip to content

Commit 2d7ae22

Browse files
committed
Updated snapshot
1 parent 60048ff commit 2d7ae22

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

jest/__snapshots__/bundles-snapshot.test.js.snap

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,7 @@ exports[`Dist bundle is unchanged 1`] = `
376376
cacheSize = _ref.cacheSize;
377377
378378
validateCacheSize(cacheSize);
379-
this._cache = {};
380-
this._cacheKeys = [];
381-
this._cacheLength = 0;
379+
this.clear();
382380
this._cacheSize = cacheSize;
383381
}
384382
@@ -404,10 +402,8 @@ exports[`Dist bundle is unchanged 1`] = `
404402
405403
if (index > -1) {
406404
delete this._cache[key];
407-
var lastIndex = this._cacheLength - 1;
408-
var lastKey = this._cacheKeys[lastIndex];
409-
this._cacheKeys[index] = lastKey;
410405
this._cacheLength--;
406+
this._cacheKeys[index] = this._cacheKeys[this._cacheLength];
411407
}
412408
};
413409
@@ -419,8 +415,7 @@ exports[`Dist bundle is unchanged 1`] = `
419415
420416
_proto._randomReplace = function _randomReplace(newKey, newValue) {
421417
var index = Math.floor(Math.random() * this._cacheLength);
422-
var key = this._cacheKeys[index];
423-
delete this._cache[key];
418+
delete this._cache[this._cacheKeys[index]];
424419
this._cacheKeys[index] = newKey;
425420
this._cache[newKey] = newValue;
426421
};
@@ -460,14 +455,13 @@ exports[`Dist bundle is unchanged 1`] = `
460455
};
461456
462457
_proto.remove = function remove(key) {
463-
var index = this._cacheKeys.indexOf(key);
458+
var index = this._cacheKeys.indexOf(key); // O(1)
459+
464460
465461
if (index > -1) {
466462
delete this._cache[\\"delete\\"](key);
467-
var lastIndex = this._cacheLength - 1;
468-
var lastKey = this._cacheKeys[lastIndex];
469-
this._cacheKeys[index] = lastKey;
470463
this._cacheLength--;
464+
this._cacheKeys[index] = this._cacheKeys[this._cacheLength];
471465
}
472466
};
473467
@@ -479,9 +473,8 @@ exports[`Dist bundle is unchanged 1`] = `
479473
480474
_proto._randomReplace = function _randomReplace(newKey, newValue) {
481475
var index = Math.floor(Math.random() * this._cacheLength);
482-
var key = this._cacheKeys[index];
483476
484-
this._cache[\\"delete\\"](key);
477+
this._cache[\\"delete\\"](this._cacheKeys[index]);
485478
486479
this._cacheKeys[index] = newKey;
487480

0 commit comments

Comments
 (0)