Simplify nextMissingChunk(), getEndChunk()
This commit is contained in:
parent
83eff107ae
commit
e5477c3156
@ -131,14 +131,9 @@ var ChunkedStream = (function ChunkedStreamClosure() {
|
||||
},
|
||||
|
||||
nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
|
||||
var chunk, n;
|
||||
for (chunk = beginChunk, n = this.numChunks; chunk < n; ++chunk) {
|
||||
if (!this.loadedChunks[chunk]) {
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
// Wrap around to beginning
|
||||
for (chunk = 0; chunk < beginChunk; ++chunk) {
|
||||
var chunk, numChunks = this.numChunks;
|
||||
for (var i = 0; i < numChunks; ++i) {
|
||||
chunk = (beginChunk + i) % numChunks; // Wrap around to beginning
|
||||
if (!this.loadedChunks[chunk]) {
|
||||
return chunk;
|
||||
}
|
||||
@ -416,7 +411,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
||||
this.requestChunks(chunksToRequest, callback);
|
||||
},
|
||||
|
||||
// Groups a sorted array of chunks into as few continguous larger
|
||||
// Groups a sorted array of chunks into as few contiguous larger
|
||||
// chunks as possible
|
||||
groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
|
||||
var groupedChunks = [];
|
||||
@ -541,15 +536,6 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
||||
},
|
||||
|
||||
getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
|
||||
if (end % this.chunkSize === 0) {
|
||||
return end / this.chunkSize;
|
||||
}
|
||||
|
||||
// 0 -> 0
|
||||
// 1 -> 1
|
||||
// 99 -> 1
|
||||
// 100 -> 1
|
||||
// 101 -> 2
|
||||
var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
|
||||
return chunk;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user