stream: keep consumer state in fast mode · nodejs/node@62187ab · GitHub
Skip to content

Commit 62187ab

Browse files
mcollinaaduh95
authored andcommitted
stream: keep consumer state in fast mode
Create null-prototype share and broadcast consumer state with fast properties instead of V8 dictionary properties. Assisted-by: Pi Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: #66266 Reviewed-By: Mattias Buelens <mattias@buelens.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 215639d commit 62187ab

3 files changed

Lines changed: 45 additions & 9 deletions

File tree

Lines changed: 37 additions & 0 deletions

‎lib/internal/streams/iter/broadcast.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
ArrayPrototypePush,
1212
ArrayPrototypeShift,
1313
FunctionPrototypeCall,
14+
ObjectSetPrototypeOf,
1415
PromisePrototypeThen,
1516
PromiseReject,
1617
PromiseResolve,
@@ -185,8 +186,7 @@ class BroadcastImpl {
185186
}
186187

187188
#createRawConsumer() {
188-
const state = {
189-
__proto__: null,
189+
const state = ObjectSetPrototypeOf({
190190
// Start at the oldest buffered entry so late-joining consumers
191191
// can read data already in the buffer.
192192
cursor: this.#bufferStart,
@@ -195,7 +195,7 @@ class BroadcastImpl {
195195
pending: [],
196196
detached: false,
197197
error: kNoBroadcastError,
198-
};
198+
}, null);
199199

200200
this.#consumers.add(state);
201201
if (this.#consumers.size === 1) {

‎lib/internal/streams/iter/share.js‎

Lines changed: 5 additions & 6 deletions

0 commit comments

Comments
 (0)