We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ed5e799 commit 799e6d4Copy full SHA for 799e6d4
JavaScript/7-current.js
@@ -81,14 +81,16 @@ class UnrolledQueue {
81
82
dequeue() {
83
if (this.#length === 0) return null;
84
- const item = this.#current.dequeue();
+ const current = this.#current;
85
+ const item = current.dequeue();
86
this.#length--;
- if (this.#current.length === 0 && this.#current !== this.#head) {
87
- const node = this.#current;
88
- this.#current = this.#current.next;
89
- node.reset();
90
- this.#tail.next = node;
91
- this.#tail = node;
+ if (current.length === 0) {
+ current.reset();
+ if (current !== this.#head) {
+ this.#current = current.next;
+ this.#tail.next = current;
92
+ this.#tail = current;
93
+ }
94
}
95
return item;
96
0 commit comments