Skip to content
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

Require destinations when they are needed and do not fetch all of them in advance #5351

Merged
merged 2 commits into from
Oct 6, 2014

Conversation

timvandermeij
Copy link
Contributor

Fixes #5266.

@timvandermeij
Copy link
Contributor Author

@yurydelendik This PR is ready for review now that I also implemented the binary search (NameTree.get()). This patch indeed makes handling the destinations much more efficient. Could you review the patch?

@Snuffleupagus
Copy link
Collaborator

Seems to work just fine, nicely done!

Should we add a comment to the current getDestinations documentation, i.e. at api.js#L296, warning that it can be slow for large documents and advising people to use getDestination instead?

Also, please include a unit test! Something like this would probably suffice (untested, basically copied from api_spec.js#L119-L125):

it('gets destination', function() {
  var promise = doc.getDestination('chapter1');
  waitsForPromiseResolved(promise, function(data) {
    expect(data).toEqual([{ gen: 0, num: 17 }, { name: 'XYZ' },
                          0, 841.89, null]);
  });
});

@timvandermeij timvandermeij force-pushed the destinations branch 2 times, most recently from cf3ca4a to 695b3c1 Compare October 6, 2014 16:28
@timvandermeij
Copy link
Contributor Author

@Snuffleupagus Thank you. Both comments have been fixed.

var kids = root.get('Kids');
var names = root.get('Names');

if (isArray(kids)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shall repeat this as a loop until 'Kids' are found (for nested kids)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the new commit.

@yurydelendik
Copy link
Contributor

Really good. Good to go with unneeded recursion calls removed and recursion limit set.

*/
getDestinations: function PDFDocumentProxy_getDestinations() {
return this.transport.getDestinations();
},
/**
* @return {Promise} A promise that is resolved with a all information
* for a given destination ID.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"... with a all ..." looks like a typo; also this sentence can probably be simplified somewhat if you add documentation for the parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the new commit.

@timvandermeij timvandermeij force-pushed the destinations branch 4 times, most recently from 5904134 to 64efda5 Compare October 6, 2014 21:22
while (kidsOrNames.has('Kids')) {
var kids = kidsOrNames.get('Kids');

if (isArray(kids)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change that to if (!isArray(kids)) { return null; }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the new commit.

@timvandermeij timvandermeij force-pushed the destinations branch 2 times, most recently from bb12feb to 17a4283 Compare October 6, 2014 21:54
@yurydelendik
Copy link
Contributor

Looks good

@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Oct 6, 2014

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/8e54d03722943b5/output.txt

@timvandermeij
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Oct 6, 2014

From: Bot.io (Linux)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/5dbc517e79e25eb/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Oct 6, 2014

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.22.172.223:8877/0c5e21bda646117/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Oct 6, 2014

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/0c5e21bda646117/output.txt

Total script time: 19.65 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Oct 6, 2014

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/5dbc517e79e25eb/output.txt

Total script time: 22.76 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

yurydelendik added a commit that referenced this pull request Oct 6, 2014
Require destinations when they are needed and do not fetch all of them in advance
@yurydelendik yurydelendik merged commit 878fad4 into mozilla:master Oct 6, 2014
@yurydelendik
Copy link
Contributor

Thank you for the patch

@brendandahl
Copy link
Contributor

Minor version number needs to be bumped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getDestinations takes long time for pdf.pdf
5 participants