-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Refactors CMapFactory.create to make it async #7039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
return parseBinaryCMap(name, builtInCMapParams); | ||
} | ||
if (builtInCMapParams.packed) { | ||
resolve(parseBinaryCMap(name, builtInCMapParams)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In production we mostly use parseBinaryCMap
-- this shall be async too
Review status: 0 of 3 files reviewed at latest revision, 18 unresolved discussions. src/core/cmap.js, line 445 [r2] (raw file): src/core/cmap.js, line 980 [r2] (raw file): src/core/cmap.js, line 1003 [r2] (raw file): src/core/evaluator.js, line 253 [r2] (raw file): src/core/evaluator.js, line 344 [r2] (raw file): src/core/evaluator.js, line 430 [r2] (raw file): src/core/evaluator.js, line 508 [r2] (raw file): src/core/evaluator.js, line 803 [r2] (raw file): src/core/evaluator.js, line 827 [r2] (raw file): src/core/evaluator.js, line 1187 [r2] (raw file): src/core/evaluator.js, line 1555 [r2] (raw file): src/core/evaluator.js, line 1653 [r2] (raw file): Comments from the review on Reviewable.io |
@yurydelendik [TYPO EDIT] I'll squash all the commits at the end when the code review is done. Okay? I was using |
You can squash commits as you pushing updated version to this PR (reviewable shall be able to track that I hope). |
Looks good so far. One or two thing are left: chaining promises at extractDataStructures and translateFont. Thanks Reviewed 1 of 3 files at r1, 2 of 2 files at r3. src/core/cmap.js, line 445 [r2] (raw file): src/core/cmap.js, line 980 [r2] (raw file): src/core/cmap.js, line 1003 [r2] (raw file): src/core/evaluator.js, line 2086 [r1] (raw file): src/core/evaluator.js, line 253 [r2] (raw file): src/core/evaluator.js, line 1555 [r2] (raw file): Comments from the review on Reviewable.io |
Review status: all files reviewed at latest revision, 3 unresolved discussions. src/core/cmap.js, line 445 [r2] (raw file): Can you help me understand this?
Can this be safely removed too? src/core/evaluator.js, line 253 [r2] (raw file): Comments from the review on Reviewable.io |
Review status: all files reviewed at latest revision, 3 unresolved discussions. src/core/cmap.js, line 445 [r2] (raw file): Comments from the review on Reviewable.io |
Review status: 1 of 3 files reviewed at latest revision, 3 unresolved discussions. src/core/evaluator.js, line 253 [r2] (raw file): Comments from the review on Reviewable.io |
Reviewed 2 of 2 files at r4. src/core/cmap.js, line 445 [r2] (raw file): src/core/cmap.js, line 446 [r4] (raw file): Comments from the review on Reviewable.io |
Review status: 2 of 3 files reviewed at latest revision, 2 unresolved discussions. src/core/cmap.js, line 446 [r4] (raw file): Comments from the review on Reviewable.io |
Reviewed 1 of 1 files at r5. src/core/cmap.js, line 429 [r5] (raw file): src/core/evaluator.js, line 345 [r5] (raw file): Comments from the review on Reviewable.io |
Review status: 1 of 3 files reviewed at latest revision, 3 unresolved discussions. src/core/evaluator.js, line 345 [r5] (raw file): Comments from the review on Reviewable.io |
Review status: 1 of 3 files reviewed at latest revision, 5 unresolved discussions. src/core/cmap.js, line 718 [r5] (raw file): src/core/cmap.js, line 958 [r5] (raw file): Comments from the review on Reviewable.io |
Review status: 1 of 3 files reviewed at latest revision, 4 unresolved discussions. src/core/cmap.js, line 958 [r5] (raw file): Comments from the review on Reviewable.io |
Review status: 1 of 3 files reviewed at latest revision, 4 unresolved discussions. src/core/cmap.js, line 958 [r5] (raw file): Comments from the review on Reviewable.io |
Here function async status (-> is a call):
Problem we have parseCMap and buildToUnicode is sync. Former is easy to convert, the latter is hard. Let's move buildToUnicode body into evaluator near extractDataStructures and chain its call after toUnicode. Review status: 1 of 3 files reviewed at latest revision, 6 unresolved discussions. src/core/evaluator.js, line 1640 [r5] (raw file): src/core/evaluator.js, line 1655 [r5] (raw file): Comments from the review on Reviewable.io |
Review status: 1 of 3 files reviewed at latest revision, 6 unresolved discussions. src/core/cmap.js, line 958 [r5] (raw file): Comments from the review on Reviewable.io |
Review status: 1 of 3 files reviewed at latest revision, 5 unresolved discussions. src/core/evaluator.js, line 1640 [r5] (raw file): Comments from the review on Reviewable.io |
Reviewed 1 of 2 files at r7, 1 of 1 files at r8. src/core/cmap.js, line 938 [r8] (raw file): src/core/evaluator.js, line 1640 [r5] (raw file):
We will refactor the logic of buildToUnicode later. Comments from the review on Reviewable.io |
I recommend to rebase it to the newest mozilla/master before moving buildToUnicode (I saw some of PRs landed that will affect it) |
Sure. Thanks for the heads up |
Review status: all files reviewed at latest revision, 13 unresolved discussions. src/core/evaluator.js, line 1655 [r5] (raw file): Comments from the review on Reviewable.io |
Review status: all files reviewed at latest revision, 12 unresolved discussions. src/core/evaluator.js, line 1653 [r10] (raw file): Comments from the review on Reviewable.io |
|
||
// The viewer's choice, just use an identity map. | ||
return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, | ||
properties.lastChar)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: please indent this line a bit more, like this
return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar,
properties.lastChar));
Review status: all files reviewed at latest revision, 12 unresolved discussions. src/core/evaluator.js, line 354 [r11] (raw file): Comments from the review on Reviewable.io |
Review status: 1 of 3 files reviewed at latest revision, 14 unresolved discussions. src/core/evaluator.js, line 2133 [r13] (raw file): src/core/evaluator.js, line 2232 [r13] (raw file): Comments from the review on Reviewable.io |
Reviewed 1 of 2 files at r12, 1 of 1 files at r14. Comments from the review on Reviewable.io |
cmap_spec needs to be fixed, e.g.:
|
Review status: all files reviewed at latest revision, 14 unresolved discussions. src/core/evaluator.js, line 354 [r11] (raw file): Comments from the review on Reviewable.io |
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null); | ||
properties.vertical = properties.cMap.vertical; | ||
return CMapFactory.create(cidEncoding, | ||
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chain that with this.buildToUnicode call -- we need properties.toUnicode populated before new Font() call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it would be
return CMapFactory.create(cidEncoding,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
function (cMap) {
properties.cMap = cMap;
properties.vertical = properties.cMap.vertical;
return this.buildToUnicode(cMap.properties)
}.bind(this)).then(function (toUnicode) {
properties.toUnicode = toUnicode;
return new Font(fontName.name, fontFile, properties);
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make there return this.buildToUnicode(properties);
though
r+ when all tests pass, looks good in terms of refactored logic. |
@prometheansacrifice There are still some test failures. Once those are fixed I'll review. |
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/9b5649f35803541/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.21.233.14:8877/256d415292652fd/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/9b5649f35803541/output.txt Total script time: 20.52 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/256d415292652fd/output.txt Total script time: 22.04 mins
|
Refactors CMapFactory.create to make it async
Thank you for the patch. Good work. |
Thank you too yury. Appreciate your help in this |
For #6352. Up for review