Merge pull request #11544 from Snuffleupagus/decodeHuffman

Make the `decodeHuffman` function, in `src/core/jpg.js`, slightly more efficient
This commit is contained in:
Tim van der Meij 2020-01-28 22:54:46 +01:00 committed by GitHub
commit 7ae504222f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -178,12 +178,13 @@ var JpegImage = (function JpegImageClosure() {
var node = tree;
while (true) {
node = node[readBit()];
if (typeof node === "number") {
return node;
}
if (typeof node !== "object") {
throw new JpegError("invalid huffman sequence");
switch (typeof node) {
case "number":
return node;
case "object":
continue;
}
throw new JpegError("invalid huffman sequence");
}
}