1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Don't get bytes eagerly when creating {Jpeg,Jpx,Jbig2}Stream objects.

This avoids lots of unnecessary work when such streams are referred to via
fetch(), and so their bytes aren't subsequently read. This is a large
performance win on some files.
This commit is contained in:
Nicholas Nethercote 2014-03-06 17:07:02 -08:00
parent f12d588258
commit d0253c8291
2 changed files with 35 additions and 14 deletions

View file

@ -300,12 +300,10 @@ var Parser = (function ParserClosure() {
return new LZWStream(stream, earlyChange);
}
if (name == 'DCTDecode' || name == 'DCT') {
var bytes = stream.getBytes(length);
return new JpegStream(bytes, stream.dict, this.xref);
return new JpegStream(stream, length, stream.dict, this.xref);
}
if (name == 'JPXDecode' || name == 'JPX') {
var bytes = stream.getBytes(length);
return new JpxStream(bytes, stream.dict);
return new JpxStream(stream, length, stream.dict);
}
if (name == 'ASCII85Decode' || name == 'A85') {
return new Ascii85Stream(stream);
@ -320,8 +318,7 @@ var Parser = (function ParserClosure() {
return new RunLengthStream(stream);
}
if (name == 'JBIG2Decode') {
var bytes = stream.getBytes(length);
return new Jbig2Stream(bytes, stream.dict);
return new Jbig2Stream(stream, length, stream.dict);
}
warn('filter "' + name + '" not supported yet');
return stream;