Skip to content

Commit

Permalink
fix: avoid frequent reslices of queue for semaphore use case
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge authored Aug 15, 2024
1 parent 7dc5a70 commit 7f27bdb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Queue<T> {

const item = this.items[this.offset];
this.offset++;
if (this.offset * 2 >= this.items.length) {
if (this.items.length > 32 && this.offset * 2 >= this.items.length) {
this.items = this.items.slice(this.offset);
this.offset = 0;
}
Expand Down

0 comments on commit 7f27bdb

Please sign in to comment.