Skip to content

Commit 6e2b57b

Browse files
committed
perf: reduce branching in hot code paths
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
1 parent 3cbcacc commit 6e2b57b

12 files changed

+106
-118
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ and this project adheres to
88

99
## [Unreleased]
1010

11+
### Changed
12+
13+
- Reduce branching in several hot code paths.
14+
1115
## [0.1.11] - 2023-12-25
1216

1317
### Fixed

src/deque.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class Deque<T> {
7979
return
8080
}
8181
const tail = this.tail
82-
this.tail = (this.tail as Node<T>).prev
82+
this.tail = this.tail!.prev
8383
if (this.tail == null) {
8484
delete this.head
8585
} else {
@@ -155,7 +155,7 @@ export class Deque<T> {
155155
value: node.data,
156156
done: false,
157157
}
158-
node = node.next as Node<T>
158+
node = node.next
159159
return ret
160160
},
161161
}
@@ -183,7 +183,7 @@ export class Deque<T> {
183183
value: node.data,
184184
done: false,
185185
}
186-
node = node.prev as Node<T>
186+
node = node.prev
187187
return ret
188188
},
189189
}

0 commit comments

Comments
 (0)