We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 12a5d91 commit 608ec41Copy full SHA for 608ec41
fixed-deque.js
@@ -48,7 +48,9 @@ FixedDeque.prototype.push = function(item) {
48
if (this.size === this.capacity)
49
throw new Error('mnemonist/fixed-deque.push: deque capacity (' + this.capacity + ') exceeded!');
50
51
- var index = (this.start + this.size) % this.capacity;
+ var index = this.start + this.size;
52
+ if (index >= this.capacity)
53
+ index -= this.capacity;
54
55
this.items[index] = item;
56
@@ -85,7 +87,9 @@ FixedDeque.prototype.pop = function() {
85
87
if (this.size === 0)
86
88
return;
89
- const index = (this.start + this.size - 1) % this.capacity;
90
+ var index = this.start + this.size - 1;
91
+ if (index > this.capacity)
92
93
94
this.size--;
95
0 commit comments