From 9119409a3390118a3397046dbc9aef074300bf28 Mon Sep 17 00:00:00 2001 From: Yomguithereal Date: Fri, 2 Feb 2024 11:06:38 +0100 Subject: [PATCH] Updating changelog with FixedDeque improvements by @jerome-benoit --- CHANGELOG.md | 1 + fixed-deque.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 488bc9f1..4d7ec193 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.39.8 (provisional) * Fixing `Float64Vector` TS exports (@atombrenner). +* Improving performance of `FixedDeque` `#.push` & `#.pop` methods (@jerome-benoit). ## 0.39.7 diff --git a/fixed-deque.js b/fixed-deque.js index ba3a6e40..6a81fe1c 100644 --- a/fixed-deque.js +++ b/fixed-deque.js @@ -49,6 +49,7 @@ FixedDeque.prototype.push = function(item) { throw new Error('mnemonist/fixed-deque.push: deque capacity (' + this.capacity + ') exceeded!'); var index = this.start + this.size; + if (index >= this.capacity) index -= this.capacity; @@ -88,6 +89,7 @@ FixedDeque.prototype.pop = function() { return; var index = this.start + this.size - 1; + if (index > this.capacity) index -= this.capacity;