Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
tyoshino committed Jun 5, 2015
1 parent 187172e commit 3f7fd74
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions reference-implementation/lib/readable-byte-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class ReadableByteStreamController {
EnqueueInReadableByteStreamController(this, chunk);

if (this._pendingPulls.length > 0) {
ProcessPullRequest(stream, this._pendingPulls.shift());
ProcessPullRequest(stream);
}

return undefined;
Expand Down Expand Up @@ -253,7 +253,7 @@ class ReadableByteStreamController {
EnqueueInReadableByteStreamController(this, buffer.slice(result.bytesUsed, descriptor.bytesFilled));

if (this._pendingPulls.length > 0) {
while (ProcessPullRequest(stream, this._pendingPulls.shift())) {}
while (ProcessPullRequest(stream)) {}
}
}
} else {
Expand Down Expand Up @@ -557,13 +557,8 @@ function DetachReadableByteStreamReader(reader) {
}

function EnqueueInReadableByteStreamController(controller, chunk) {
try {
controller._queue.push({buffer: chunk.buffer, byteOffset: chunk.byteOffset, byteLength: chunk.byteLength});
controller._totalQueuedBytes += chunk.byteLength;
} catch (e) {
ErrorReadableByteStream(controller._controlledReadableByteStream, e);
throw e;
}
controller._queue.push({buffer: chunk.buffer, byteOffset: chunk.byteOffset, byteLength: chunk.byteLength});
controller._totalQueuedBytes += chunk.byteLength;

return undefined;
}
Expand Down Expand Up @@ -700,6 +695,12 @@ function IsReadableByteStreamReader(x) {
}

function ProcessPullRequest(stream, descriptor) {
let detachRequired = true;
if (descriptor === undefined) {
descriptor = this._pendingPulls.shift();
detachRequired = false;
}

const controller = stream._controller;

const queue = controller._queue;
Expand Down Expand Up @@ -761,7 +762,7 @@ function ProcessPullRequest(stream, descriptor) {
return false;
}

// TODO: Detach destBuffer here.
// TODO: Detach descriptor.buffer if detachRequired is true.
controller._pendingPulls.push(descriptor);
try {
controller._underlyingByteSource.pullInto(
Expand Down

0 comments on commit 3f7fd74

Please sign in to comment.