Skip to content

Commit 6466ba9

Browse files
negezorlukekarrys
andauthoredMay 9, 2024··
fix(lru): use map.delete() directly (#713)
The default implementation already returns boolean if the value has been deleted. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete#return_value It's also faster since we don't double check the hashmap for a value. --------- Co-authored-by: Luke Karrys <luke@lukekarrys.com>
1 parent d777418 commit 6466ba9

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed
 

‎internal/lrucache.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ class LRUCache {
1717
}
1818

1919
delete (key) {
20-
if (this.map.has(key)) {
21-
this.map.delete(key)
22-
return true
23-
} else {
24-
return false
25-
}
20+
return this.map.delete(key)
2621
}
2722

2823
set (key, value) {

0 commit comments

Comments
 (0)
Please sign in to comment.