Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
saschanaz committed Dec 22, 2024
1 parent 7d14024 commit d221af0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3459,16 +3459,16 @@ The following abstract operations support the implementation of the
|pullIntoDescriptor|'s [=pull-into descriptor/bytes filled=].
1. Let |descriptorBuffer| be |pullIntoDescriptor|'s [=pull-into descriptor/buffer=].
1. Let |queueBuffer| be |headOfQueue|'s [=readable byte stream queue entry/buffer=].
1. Let |queueByteOffset| be |headOfQueue|'s [=readable byte stream queue entry/byte offset=].
1. Assert: ! [$CanCopyDataBlockBytes$](|descriptorBuffer|, |destStart|, |queueBuffer|,
|headOfQueue|'s [=readable byte stream queue entry/byte offset=], |bytesToCopy|) is true.
|queueByteOffset|, |bytesToCopy|) is true.
<p class="warning">If this assertion were to fail (due to a bug in this specification or
its implementation), then the next step may read from or write to potentially invalid memory.
The user agent should always check this assertion, and stop in an [=implementation-defined=]
manner if it fails (e.g. by crashing the process, or by
<a abstract-op lt="ReadableByteStreamControllerError">erroring the stream</a>).
1. Perform ! [$CopyDataBlockBytes$](|descriptorBuffer|.\[[ArrayBufferData]], |destStart|,
|queueBuffer|.\[[ArrayBufferData]], |headOfQueue|'s [=readable byte stream queue entry/byte
offset=], |bytesToCopy|).
|queueBuffer|.\[[ArrayBufferData]], |queueByteOffset|, |bytesToCopy|).
1. If |headOfQueue|'s [=readable byte stream queue entry/byte length=] is |bytesToCopy|,
1. [=list/Remove=] |queue|[0].
1. Otherwise,
Expand Down
13 changes: 7 additions & 6 deletions reference-implementation/lib/abstract-ops/readable-streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ function ReadableByteStreamControllerEnqueue(controller, chunk) {
ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
const filledPullIntos = ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
for (const filledPullInto of filledPullIntos) {
ReadableByteStreamControllerCommitPullIntoDescriptor(controller._stream, filledPullInto);
ReadableByteStreamControllerCommitPullIntoDescriptor(stream, filledPullInto);
}
} else {
assert(IsReadableStreamLocked(stream) === false);
Expand Down Expand Up @@ -1448,9 +1448,12 @@ function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller,

const destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;

assert(CanCopyDataBlockBytes(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset,
const descriptorBuffer = pullIntoDescriptor.buffer;
const queueBuffer = headOfQueue.buffer;
const queueByteOffset = headOfQueue.byteOffset;
assert(CanCopyDataBlockBytes(descriptorBuffer, destStart, queueBuffer, queueByteOffset,
bytesToCopy));
CopyDataBlockBytes(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy);
CopyDataBlockBytes(descriptorBuffer, destStart, queueBuffer, queueByteOffset, bytesToCopy);

if (headOfQueue.byteLength === bytesToCopy) {
queue.shift();
Expand Down Expand Up @@ -1680,11 +1683,9 @@ function ReadableByteStreamControllerRespondInClosedState(controller, firstDescr
const stream = controller._stream;
if (ReadableStreamHasBYOBReader(stream) === true) {
const filledPullIntos = [];
let i = 0;
while (i < ReadableStreamGetNumReadIntoRequests(stream)) {
while (filledPullIntos.length < ReadableStreamGetNumReadIntoRequests(stream)) {
const pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);
filledPullIntos.push(pullIntoDescriptor);
++i;
}
for (const filledPullInto of filledPullIntos) {
ReadableByteStreamControllerCommitPullIntoDescriptor(stream, filledPullInto);
Expand Down

0 comments on commit d221af0

Please sign in to comment.