File tree 1 file changed +10
-10
lines changed
1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -69,9 +69,9 @@ class UnrolledQueue {
69
69
if ( ! this . #current. enqueue ( item ) ) {
70
70
if ( this . #current === this . #head) {
71
71
const node = this . #createNode( ) ;
72
- node . next = this . #head;
73
- this . #head = node ;
74
72
this . #current. next = node ;
73
+ this . #current = node ;
74
+ this . #head = node ;
75
75
} else {
76
76
this . #current = this . #current. next ;
77
77
}
@@ -82,15 +82,15 @@ class UnrolledQueue {
82
82
83
83
dequeue ( ) {
84
84
if ( this . #length === 0 ) return null ;
85
- const tail = this . #tail;
86
- if ( tail . length === 0 ) {
87
- this . #tail = tail . next ;
88
- tail . reset ( ) ;
89
- this . #head. next = tail ;
90
- this . #head = tail ;
91
- }
92
- const item = this . #tail. dequeue ( ) ;
85
+ const node = this . #tail;
86
+ const item = node . dequeue ( ) ;
93
87
this . #length-- ;
88
+ if ( node . length === 0 && node !== this . #current) {
89
+ this . #tail = node . next ;
90
+ node . reset ( ) ;
91
+ this . #head. next = node ;
92
+ this . #head = node ;
93
+ }
94
94
return item ;
95
95
}
96
96
}
You can’t perform that action at this time.
0 commit comments