Skip to content

Commit

Permalink
Slight optimization of LRU #.setpop
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomguithereal committed Dec 21, 2023
1 parent f7563f4 commit 8453d82
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.39.7 (provisional)

* Slight performance optimization of LRU classes `#.setpop` method.

## 0.39.6

* Fixing type declarations of `FibonacciHeap`, `StaticIntervalTree` & `Vector` (@Macil).
Expand Down
2 changes: 1 addition & 1 deletion lru-cache-with-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ LRUCacheWithDelete.prototype.setpop = function(key, value) {
this.tail = this.backward[pointer];
oldValue = this.V[pointer];
oldKey = this.K[pointer];
delete this.items[this.K[pointer]];
delete this.items[oldKey];
}

// Storing key & value
Expand Down
2 changes: 1 addition & 1 deletion lru-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ LRUCache.prototype.setpop = function(key, value) {
this.tail = this.backward[pointer];
oldValue = this.V[pointer];
oldKey = this.K[pointer];
delete this.items[this.K[pointer]];
delete this.items[oldKey];
}

// Storing key & value
Expand Down
2 changes: 1 addition & 1 deletion lru-map-with-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ LRUMapWithDelete.prototype.setpop = function(key, value) {
this.tail = this.backward[pointer];
oldValue = this.V[pointer];
oldKey = this.K[pointer];
this.items.delete(this.K[pointer]);
this.items.delete(oldKey);
}

// Storing key & value
Expand Down
2 changes: 1 addition & 1 deletion lru-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ LRUMap.prototype.setpop = function(key, value) {
this.tail = this.backward[pointer];
oldValue = this.V[pointer];
oldKey = this.K[pointer];
this.items.delete(this.K[pointer]);
this.items.delete(oldKey);
}

// Storing key & value
Expand Down

0 comments on commit 8453d82

Please sign in to comment.