Skip to content

Commit fd9990e

Browse files
committed
Optimize end detecting
1 parent 4e9064a commit fd9990e

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

Diff for: JavaScript/4-unrolled.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ class QueueNode {
1111
}
1212

1313
enqueue(item) {
14-
if (this.length === this.size || this.writeIndex >= this.size) {
15-
return false;
16-
}
14+
if (this.writeIndex >= this.size) return false;
1715
this.buffer[this.writeIndex++] = item;
1816
this.length++;
1917
return true;

Diff for: TypeScript/queue.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ class QueueNode {
1111
}
1212

1313
enqueue(item) {
14-
if (this.length === this.size || this.writeIndex >= this.size) {
15-
return false;
16-
}
14+
if (this.writeIndex >= this.size) return false;
1715
this.buffer[this.writeIndex++] = item;
1816
this.length++;
1917
return true;

0 commit comments

Comments
 (0)