[Pkg-javascript-commits] [pdf.js] 01/157: Simplify nextMissingChunk(), getEndChunk()
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 06:46:23 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit e5477c3156a1b5dcb8f7ba3763c5d327d11cc573
Author: fkaelberer <l_l at gmx-topmail.de>
Date: Tue Sep 30 19:42:50 2014 +0200
Simplify nextMissingChunk(), getEndChunk()
---
src/core/chunked_stream.js | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/src/core/chunked_stream.js b/src/core/chunked_stream.js
index 3bc293a..6522532 100644
--- a/src/core/chunked_stream.js
+++ b/src/core/chunked_stream.js
@@ -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;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list