mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
stream: optimize single-slot push queue drain
Avoid allocating a new result array when PushQueue drains a single queued slot. Return that slot directly and keep the existing flattening path for multiple queued slots. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: openai:gpt-5.5 PR-URL: https://github.com/nodejs/node/pull/63274 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
This commit is contained in:
1 parent
e5686734ee
commit
be7ded1693
1 file changed
+4
@@ -448,6 +448,10 @@ class PushQueue {
|
||||
// ===========================================================================
|
||||
|
||||
#drain() {
|
||||
if (this.#slots.length === 1) {
|
||||
return this.#slots.shift();
|
||||
}
|
||||
|
||||
const result = [];
|
||||
for (let i = 0; i < this.#slots.length; i++) {
|
||||
const slot = this.#slots.get(i);
|
||||
|
||||
Reference in new issue
Block a user