From c6ddbd55e2f30842499c200cffa309f7c78fa290 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 29 Mar 2019 19:57:52 +0100 Subject: [PATCH] Add a `progressiveDataLength` fast-path to `ChunkedStream.ensureByte` This is *similar* to the existing check using in `ChunkedStream.ensureRange`. --- src/core/chunked_stream.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/chunked_stream.js b/src/core/chunked_stream.js index 0be3140b0..26a93f673 100644 --- a/src/core/chunked_stream.js +++ b/src/core/chunked_stream.js @@ -98,6 +98,10 @@ class ChunkedStream { } ensureByte(pos) { + if (pos < this.progressiveDataLength) { + return; + } + const chunk = Math.floor(pos / this.chunkSize); if (chunk === this.lastSuccessfulEnsureByteChunk) { return;