stream: consolidate non-op algorithm callbacks · nodejs/node@4d29742 · GitHub
Skip to content

Commit 4d29742

Browse files
mcollinaaduh95
authored andcommitted
stream: consolidate non-op algorithm callbacks
The start, pull, and write non-op algorithms are all raw callbacks with an identical empty body now, so a single shared nonOpCallback replaces nonOpStart, nonOpPull, and nonOpWrite. Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: #65138 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent f7e0c81 commit 4d29742

3 files changed

Lines changed: 19 additions & 25 deletions

File tree

lib/internal/webstreams/readablestream.js

Lines changed: 10 additions & 11 deletions

lib/internal/webstreams/util.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,17 +418,14 @@ function setPromiseHandled(promise) {
418418

419419
async function nonOpFlush() {}
420420

421-
function nonOpStart() {}
422-
423-
// nonOpPull and nonOpWrite are raw callbacks (see createRawCallback*):
424-
// their non-thenable return takes the allocation-free fast path in
421+
// Shared non-op for the start/pull/write algorithm callbacks, which all
422+
// follow the raw-callback contract (see createRawCallback*): the
423+
// non-thenable return takes the allocation-free fast path in
425424
// thenAlgorithmResult().
426-
function nonOpPull() {}
425+
function nonOpCallback() {}
427426

428427
async function nonOpCancel() {}
429428

430-
function nonOpWrite() {}
431-
432429
let transfer;
433430
function lazyTransfer() {
434431
if (transfer === undefined)
@@ -465,11 +462,10 @@ module.exports = {
465462
kType,
466463
lazyTransfer,
467464
materializeQueue,
465+
nonOpCallback,
468466
nonOpCancel,
469467
nonOpFlush,
470-
nonOpPull,
471-
nonOpStart,
472-
nonOpWrite,
468+
473469
peekQueueValue,
474470
rejectedHandledRecord,
475471
resetQueue,

lib/internal/webstreams/writablestream.js

Lines changed: 3 additions & 4 deletions

0 commit comments

Comments
 (0)