Add a getArrayLookupTableFactory helper function and use it to re-format src/core/{glyphlist, unicode}.js

*Please note:* Once https://bugzilla.mozilla.org/show_bug.cgi?id=1247687 is implemented, and we've removed SystemJS completely, this entire patch can (and even should) be reverted.

This is similar to the existing `getLookupTableFactory` helper function, but is implemented as outlined in issue 6774.
The re-formatting of the tables were done automatically, by using find-and-replace with regular expressions.

For reasons that I don't even pretend to understand, using this particular structure for these *very* long lookup tables allow SystemJS to process the files correctly/quickly and the development viewer thus works as intended.
This commit is contained in:
Jonas Jenwald 2020-10-25 13:06:27 +01:00
parent 441d9c8cc0
commit 56fa6d414c
3 changed files with 5937 additions and 5908 deletions

View File

@ -27,6 +27,22 @@ function getLookupTableFactory(initializer) {
};
}
function getArrayLookupTableFactory(initializer) {
let lookup;
return function () {
if (initializer) {
let arr = initializer();
initializer = null;
lookup = Object.create(null);
for (let i = 0, ii = arr.length; i < ii; i += 2) {
lookup[arr[i]] = arr[i + 1];
}
arr = null;
}
return lookup;
};
}
class MissingDataException extends BaseException {
constructor(begin, end) {
super(`Missing data [${begin}, ${end})`);
@ -212,6 +228,7 @@ function escapePDFName(str) {
export {
escapePDFName,
getLookupTableFactory,
getArrayLookupTableFactory,
MissingDataException,
XRefEntryException,
XRefParseException,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff