Skip to content

Commit 1590809

Browse files
committed
replace # with private to improve performance
1 parent 322f644 commit 1590809

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

packages/client/lib/client/queue.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,84 +5,84 @@ export interface QueueNode<T> {
55
}
66

77
export default class Queue<T> {
8-
#length = 0;
8+
private _length = 0;
99

1010
get length() {
11-
return this.#length;
11+
return this._length;
1212
}
1313

14-
#head: QueueNode<T> | null = null;
14+
private _head: QueueNode<T> | null = null;
1515

1616
get head() {
17-
return this.#head;
17+
return this._head;
1818
}
1919

20-
#tail: QueueNode<T> | null = null;
20+
_tail: QueueNode<T> | null = null;
2121

2222
get tail() {
23-
return this.#tail;
23+
return this._tail;
2424
}
2525

2626
push(value: T) {
27-
++this.#length;
27+
++this._length;
2828

29-
if (!this.#tail) {
30-
return this.#tail = this.#head = {
31-
previous: this.#head,
29+
if (!this._tail) {
30+
return this._tail = this._head = {
31+
previous: this._head,
3232
next: null,
3333
value
3434
};
3535
}
3636

37-
return this.#tail = this.#tail.next = {
38-
previous: this.#tail,
37+
return this._tail = this._tail.next = {
38+
previous: this._tail,
3939
next: null,
4040
value
4141
};
4242
}
4343

4444
unshift(value: T) {
45-
++this.#length;
45+
++this._length;
4646

47-
if (!this.#head) {
48-
return this.#head = this.#tail = {
47+
if (!this._head) {
48+
return this._head = this._tail = {
4949
previous: null,
5050
next: null,
5151
value
5252
};
5353
}
5454

55-
return this.#head = this.#head.previous = {
55+
return this._head = this._head.previous = {
5656
previous: null,
57-
next: this.#head,
57+
next: this._head,
5858
value
5959
};
6060
}
6161

6262
shift() {
63-
if (!this.#head) return null;
63+
if (!this._head) return null;
6464

65-
--this.#length;
66-
const node = this.#head;
65+
--this._length;
66+
const node = this._head;
6767
if (node.next) {
6868
node.next.previous = node.previous;
69-
this.#head = node.next;
69+
this._head = node.next;
7070
node.next = null;
7171
} else {
72-
this.#head = this.#tail = null;
72+
this._head = this._tail = null;
7373
}
7474
return node.value;
7575
}
7676

7777
remove(node: QueueNode<T>) {
78-
--this.#length;
78+
--this._length;
7979

80-
if (this.#tail === node) {
81-
this.#tail = node.previous;
80+
if (this._tail === node) {
81+
this._tail = node.previous;
8282
}
8383

84-
if (this.#head === node) {
85-
this.#head = node.next;
84+
if (this._head === node) {
85+
this._head = node.next;
8686
} else {
8787
node.previous!.next = node.next;
8888
node.previous = null;
@@ -92,7 +92,7 @@ export default class Queue<T> {
9292
}
9393

9494
*[Symbol.iterator]() {
95-
let node = this.#head;
95+
let node = this._head;
9696
while (node !== null) {
9797
yield node.value;
9898
node = node.next;

0 commit comments

Comments
 (0)