Revert "working on optimizations"
This reverts commit 03747940a2f8346e484898b026f43785c25abd04.
This commit is contained in:
parent
03747940a2
commit
b83979f40d
58
pdf.js
58
pdf.js
@ -104,15 +104,11 @@ var Stream = (function() {
|
|||||||
dest[n++] = bytes[pos++];
|
dest[n++] = bytes[pos++];
|
||||||
this.pos = this.end;
|
this.pos = this.end;
|
||||||
},
|
},
|
||||||
skip: function() {
|
skip: function(n) {
|
||||||
this.pos += 1;
|
if (!n)
|
||||||
},
|
n = 1;
|
||||||
skipN: function(n) {
|
|
||||||
this.pos += n;
|
this.pos += n;
|
||||||
},
|
},
|
||||||
back: function() {
|
|
||||||
this.pos -= 1;
|
|
||||||
},
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
this.pos = this.start;
|
this.pos = this.start;
|
||||||
},
|
},
|
||||||
@ -323,7 +319,7 @@ var FlateStream = (function() {
|
|||||||
getByte: function() {
|
getByte: function() {
|
||||||
var bufferLength = this.bufferLength;
|
var bufferLength = this.bufferLength;
|
||||||
var bufferPos = this.bufferPos;
|
var bufferPos = this.bufferPos;
|
||||||
if (bufferLength <= bufferPos) {
|
if (bufferLength == bufferPos) {
|
||||||
if (this.eof)
|
if (this.eof)
|
||||||
return;
|
return;
|
||||||
this.readBlock();
|
this.readBlock();
|
||||||
@ -353,7 +349,7 @@ var FlateStream = (function() {
|
|||||||
lookChar: function() {
|
lookChar: function() {
|
||||||
var bufferLength = this.bufferLength;
|
var bufferLength = this.bufferLength;
|
||||||
var bufferPos = this.bufferPos;
|
var bufferPos = this.bufferPos;
|
||||||
if (bufferLength <= bufferPos) {
|
if (bufferLength == bufferPos) {
|
||||||
if (this.eof)
|
if (this.eof)
|
||||||
return;
|
return;
|
||||||
this.readBlock();
|
this.readBlock();
|
||||||
@ -384,16 +380,11 @@ var FlateStream = (function() {
|
|||||||
// update stream position
|
// update stream position
|
||||||
this.pos = n;
|
this.pos = n;
|
||||||
},
|
},
|
||||||
skip: function() {
|
skip: function(n) {
|
||||||
this.bufferPos++;
|
if (!n)
|
||||||
//this.getByte();
|
n = 1;
|
||||||
},
|
while (n-- > 0)
|
||||||
skipN: function(n) {
|
this.getChar();
|
||||||
this.bufferPos += n;
|
|
||||||
//this.getBytes(n);
|
|
||||||
},
|
|
||||||
back: function() {
|
|
||||||
this.bufferPos--;
|
|
||||||
},
|
},
|
||||||
generateHuffmanTable: function(lengths) {
|
generateHuffmanTable: function(lengths) {
|
||||||
var n = lengths.length;
|
var n = lengths.length;
|
||||||
@ -618,19 +609,19 @@ var Ref = (function() {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
function IsBool(v) {
|
function IsBool(v) {
|
||||||
return typeof v === "boolean";
|
return typeof v == "boolean";
|
||||||
}
|
}
|
||||||
|
|
||||||
function IsInt(v) {
|
function IsInt(v) {
|
||||||
return typeof v === "number" && ((v|0) === v);
|
return typeof v == "number" && ((v|0) == v);
|
||||||
}
|
}
|
||||||
|
|
||||||
function IsNum(v) {
|
function IsNum(v) {
|
||||||
return typeof v === "number";
|
return typeof v == "number";
|
||||||
}
|
}
|
||||||
|
|
||||||
function IsString(v) {
|
function IsString(v) {
|
||||||
return typeof v === "string";
|
return typeof v == "string";
|
||||||
}
|
}
|
||||||
|
|
||||||
function IsNull(v) {
|
function IsNull(v) {
|
||||||
@ -642,11 +633,11 @@ function IsName(v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function IsCmd(v, cmd) {
|
function IsCmd(v, cmd) {
|
||||||
return v instanceof Cmd && (!cmd || v.cmd === cmd);
|
return v instanceof Cmd && (!cmd || v.cmd == cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
function IsDict(v, type) {
|
function IsDict(v, type) {
|
||||||
return v instanceof Dict && (!type || v.get("Type").name === type);
|
return v instanceof Dict && (!type || v.get("Type").name == type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function IsArray(v) {
|
function IsArray(v) {
|
||||||
@ -664,13 +655,13 @@ function IsRef(v) {
|
|||||||
var EOF = {};
|
var EOF = {};
|
||||||
|
|
||||||
function IsEOF(v) {
|
function IsEOF(v) {
|
||||||
return v === EOF;
|
return v == EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
var None = {};
|
var None = {};
|
||||||
|
|
||||||
function IsNone(v) {
|
function IsNone(v) {
|
||||||
return v === None;
|
return v == None;
|
||||||
}
|
}
|
||||||
|
|
||||||
var Lexer = (function() {
|
var Lexer = (function() {
|
||||||
@ -723,24 +714,23 @@ var Lexer = (function() {
|
|||||||
var str = ch;
|
var str = ch;
|
||||||
var stream = this.stream;
|
var stream = this.stream;
|
||||||
do {
|
do {
|
||||||
ch = stream.getChar();
|
ch = stream.lookChar();
|
||||||
if (ch === "." && !floating) {
|
if (ch == "." && !floating) {
|
||||||
str += ch;
|
str += ch;
|
||||||
floating = true;
|
floating = true;
|
||||||
} else if (ch === "-") {
|
} else if (ch == "-") {
|
||||||
// ignore minus signs in the middle of numbers to match
|
// ignore minus signs in the middle of numbers to match
|
||||||
// Adobe's behavior
|
// Adobe's behavior
|
||||||
warn("Badly formated number");
|
warn("Badly formated number");
|
||||||
} else if (ch >= "0" && ch <= "9") {
|
} else if (ch >= "0" && ch <= "9") {
|
||||||
str += ch;
|
str += ch;
|
||||||
} else if (ch === "e" || ch === "E") {
|
} else if (ch == "e" || ch == "E") {
|
||||||
floating = true;
|
floating = true;
|
||||||
} else {
|
} else {
|
||||||
// the last character doesn't belong to us
|
// the last character doesn't belong to us
|
||||||
stream.back();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//stream.skip();
|
stream.skip();
|
||||||
} while (true);
|
} while (true);
|
||||||
var value = parseFloat(str);
|
var value = parseFloat(str);
|
||||||
if (isNaN(value))
|
if (isNaN(value))
|
||||||
@ -1534,7 +1524,7 @@ var PDFDoc = (function() {
|
|||||||
start = 0;
|
start = 0;
|
||||||
stream.pos = start;
|
stream.pos = start;
|
||||||
if (find(stream, "startxref", 1024, true)) {
|
if (find(stream, "startxref", 1024, true)) {
|
||||||
stream.skipN(9);
|
stream.skip(9);
|
||||||
var ch;
|
var ch;
|
||||||
while (Lexer.isSpace(ch = stream.getChar()))
|
while (Lexer.isSpace(ch = stream.getChar()))
|
||||||
;
|
;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user