Use typed arrays instead of normal arrays in FlateStream.

Also fix a couple of lint warnings.
This commit is contained in:
Kalervo Kujala 2011-09-07 23:07:29 +03:00
parent fb5807721e
commit a9e0ddc22f

10
pdf.js
View File

@ -592,7 +592,7 @@ var FlateStream = (function() {
var numCodeLenCodes = this.getBits(4) + 4; var numCodeLenCodes = this.getBits(4) + 4;
// build the code lengths code table // build the code lengths code table
var codeLenCodeLengths = []; var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
for (var i = 0; i < numCodeLenCodes; ++i) for (var i = 0; i < numCodeLenCodes; ++i)
codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3); codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
@ -602,7 +602,7 @@ var FlateStream = (function() {
var len = 0; var len = 0;
var i = 0; var i = 0;
var codes = numLitCodes + numDistCodes; var codes = numLitCodes + numDistCodes;
var codeLengths = []; var codeLengths = new Uint8Array(codes);
while (i < codes) { while (i < codes) {
var code = this.getCode(codeLenCodeTab); var code = this.getCode(codeLenCodeTab);
if (code == 16) { if (code == 16) {
@ -617,9 +617,9 @@ var FlateStream = (function() {
} }
litCodeTable = litCodeTable =
this.generateHuffmanTable(codeLengths.slice(0, numLitCodes)); this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
distCodeTable = distCodeTable =
this.generateHuffmanTable(codeLengths.slice(numLitCodes, codes)); this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
} else { } else {
error('Unknown block type in flate stream'); error('Unknown block type in flate stream');
} }
@ -4825,7 +4825,7 @@ var CanvasGraphics = (function() {
var italic = fontObj.italic ? 'italic' : 'normal'; var italic = fontObj.italic ? 'italic' : 'normal';
var serif = fontObj.serif ? 'serif' : 'sans-serif'; var serif = fontObj.serif ? 'serif' : 'sans-serif';
var typeface = '"' + name + '", ' + serif var typeface = '"' + name + '", ' + serif;
var rule = italic + ' ' + bold + ' ' + size + 'px ' + typeface; var rule = italic + ' ' + bold + ' ' + size + 'px ' + typeface;
this.ctx.font = rule; this.ctx.font = rule;
} }