Skip to content

Commit 42256de

Browse files
committed
stream: keep webstreams controller state fast
Controller instances declared only [kType] and set [kState] later in the setup function, so each construction took a shape transition when setup added the slot. Declaring [kState] keeps the slot in the initial map and makes the setup assignment an in-place store. Applied to the readable default, readable byte, writable, and transform controllers so all four share the same instance shape. Assisted-by: pi Signed-off-by: Matteo Collina <hello@matteocollina.com>
1 parent bc320cd commit 42256de

3 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎lib/internal/webstreams/readablestream.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,7 @@ ObjectDefineProperties(ReadableStreamBYOBReader.prototype, {
11401140

11411141
class ReadableStreamDefaultController {
11421142
[kType] = 'ReadableStreamDefaultController';
1143+
[kState];
11431144

11441145
constructor(skipThrowSymbol = undefined) {
11451146
if (skipThrowSymbol !== kSkipThrow) {
@@ -1202,6 +1203,7 @@ ObjectDefineProperties(ReadableStreamDefaultController.prototype, {
12021203

12031204
class ReadableByteStreamController {
12041205
[kType] = 'ReadableByteStreamController';
1206+
[kState];
12051207

12061208
constructor(skipThrowSymbol = undefined) {
12071209
if (skipThrowSymbol !== kSkipThrow) {

‎lib/internal/webstreams/transformstream.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ TransferredTransformStream.prototype[kDeserialize] = () => {};
303303

304304
class TransformStreamDefaultController {
305305
[kType] = 'TransformStreamDefaultController';
306+
[kState];
306307

307308
constructor(skipThrowSymbol = undefined) {
308309
if (skipThrowSymbol !== kSkipThrow) {

‎lib/internal/webstreams/writablestream.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ ObjectDefineProperties(WritableStreamDefaultWriter.prototype, {
502502

503503
class WritableStreamDefaultController {
504504
[kType] = 'WritableStreamDefaultController';
505+
[kState];
505506

506507
constructor(skipThrowSymbol = undefined) {
507508
if (skipThrowSymbol !== kSkipThrow) {

0 commit comments

Comments
 (0)