Skip to content

Commit f8903af

Browse files
authored
perf: reduce call of has when not necessary
1 parent 5d78a9a commit f8903af

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/lru.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export class LRU {
7676
* @since 1.0.0
7777
*/
7878
delete (key) {
79-
if (this.has(key)) {
79+
const item = this.items[key];
80+
if (item !== undefined) {
8081
const item = this.items[key];
8182

8283
delete this.items[key];
@@ -176,9 +177,9 @@ export class LRU {
176177
*/
177178
expiresAt (key) {
178179
let result;
179-
180-
if (this.has(key)) {
181-
result = this.items[key].expiry;
180+
const item = this.items[key];
181+
if (item !== undefined) {
182+
result = item.expiry;
182183
}
183184

184185
return result;

0 commit comments

Comments
 (0)