mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Right-size the map
array in PartialEvaluator_readToUnicode
We can avoid a lot of intermediate resizings, by directly allocating the required number of elements for the `map` array.
This commit is contained in:
parent
20b5814249
commit
8d831449ab
3 changed files with 12 additions and 1 deletions
|
@ -306,6 +306,10 @@ var CMap = (function CMapClosure() {
|
|||
out.length = 1;
|
||||
},
|
||||
|
||||
get length() {
|
||||
return this._map.length;
|
||||
},
|
||||
|
||||
get isIdentityCMap() {
|
||||
if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
|
||||
return false;
|
||||
|
@ -382,6 +386,10 @@ var IdentityCMap = (function IdentityCMapClosure() {
|
|||
|
||||
readCharCode: CMap.prototype.readCharCode,
|
||||
|
||||
get length() {
|
||||
return 0x10000;
|
||||
},
|
||||
|
||||
get isIdentityCMap() {
|
||||
error('should not access .isIdentityCMap');
|
||||
}
|
||||
|
|
|
@ -1380,7 +1380,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
if (cmap instanceof IdentityCMap) {
|
||||
return new IdentityToUnicodeMap(0, 0xFFFF);
|
||||
}
|
||||
var map = [];
|
||||
var map = new Array(cmap.length);
|
||||
// Convert UTF-16BE
|
||||
// NOTE: cmap can be a sparse array, so use forEach instead of for(;;)
|
||||
// to iterate over all keys.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue