Skip to content

Commit 92a3b56

Browse files
leemotiveyyx990803
authored andcommitted
do not call shift if the key already exists (#2971)
1 parent 45b49e8 commit 92a3b56

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cache.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ var p = Cache.prototype
3333

3434
p.put = function (key, value) {
3535
var removed
36-
if (this.size === this.limit) {
37-
removed = this.shift()
38-
}
3936

4037
var entry = this.get(key, true)
4138
if (!entry) {
39+
if (this.size === this.limit) {
40+
removed = this.shift()
41+
}
4242
entry = {
4343
key: key
4444
}

0 commit comments

Comments
 (0)