From 6466ba9b540252db405fdd2a289dd4651495beea Mon Sep 17 00:00:00 2001 From: Vlad Date: Thu, 9 May 2024 13:02:38 +1100 Subject: [PATCH] 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 --- internal/lrucache.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/internal/lrucache.js b/internal/lrucache.js index f4a97f2e..6d89ec94 100644 --- a/internal/lrucache.js +++ b/internal/lrucache.js @@ -17,12 +17,7 @@ class LRUCache { } delete (key) { - if (this.map.has(key)) { - this.map.delete(key) - return true - } else { - return false - } + return this.map.delete(key) } set (key, value) {