mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Allocate fewer objects when parsing 2 and 4 byte chunks.
This is achieved by adding getBytes2() and getBytes4() to streams, and by changing int16() and int32() to take multiple scalar args instead of an array arg.
This commit is contained in:
parent
e5cd75083f
commit
6a75e45309
3 changed files with 101 additions and 64 deletions
|
@ -140,6 +140,20 @@ var ChunkedStream = (function ChunkedStreamClosure() {
|
|||
return this.bytes[this.pos++];
|
||||
},
|
||||
|
||||
getUint16: function ChunkedStream_getUint16() {
|
||||
var b0 = this.getByte();
|
||||
var b1 = this.getByte();
|
||||
return (b0 << 8) + b1;
|
||||
},
|
||||
|
||||
getUint32: function ChunkedStream_getUint32() {
|
||||
var b0 = this.getByte();
|
||||
var b1 = this.getByte();
|
||||
var b2 = this.getByte();
|
||||
var b3 = this.getByte();
|
||||
return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
|
||||
},
|
||||
|
||||
// returns subarray of original buffer
|
||||
// should only be read
|
||||
getBytes: function ChunkedStream_getBytes(length) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue