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

Re-factor parsing of the Linearization dictionary #5023

Merged
merged 1 commit into from
Jul 28, 2014
Merged

Re-factor parsing of the Linearization dictionary #5023

merged 1 commit into from
Jul 28, 2014

Conversation

Snuffleupagus
Copy link
Collaborator

This PR attempts to implement what @yurydelendik suggested previously in #4145 (comment).

Fixes #4143.

@yurydelendik yurydelendik self-assigned this Jul 21, 2014
}
// Shadow the properties.
shadow(this, 'length', length);
Copy link
Contributor

Choose a reason for hiding this comment

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

use this.length = length; without shadowing (here and below)

@yurydelendik
Copy link
Contributor

Looks good with comments addressed.

@Snuffleupagus
Copy link
Collaborator Author

Comments have been addressed.

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/83f0e69d4ce851e/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/83f0e69d4ce851e/output.txt

Total script time: 21.15 mins

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

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

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

Total script time: 23.19 mins

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

this.mainXRefEntriesOffset = this.getInt('T');

// Optional parameter, default value = 0.
this.pageFirst = (this.linDict.has('P') ? this.getInt('P', true) : 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: two comments above about setting properties and optional parameter are obvious we can remove those (also extra line breaks between properties assignment can be removed as well)

@Snuffleupagus
Copy link
Collaborator Author

The second round of comments have been addressed, the patch just keep getting smaller ;-)

@yurydelendik
Copy link
Contributor

Hmm, just found out that this patch raises an exception when linearization is not present. We need to restructure to avoid throw new Error('No valid linearization dictionary found.'); (I'm okay with other exceptions). How about adding Linearization.create that will contain all constructor logic and returning null for this case.

@yurydelendik
Copy link
Contributor

That means Linearization will be just a data class without logic, which allows not to store stream or parser reference in it.

@Snuffleupagus
Copy link
Collaborator Author

With the current "class-like" implementation of Linearization, I'm not sure how I'd return null from it.
@yurydelendik Are you saying that you'd prefer if Linearization is instead changed to something like the following?

var Linearization = {
  create: function (...) {
    ...
    if (nonExistent) {
      return null;
    }
    return {
      // Properties
    }
  },
  getInt: function (...) {
    ...
  },
  getHints: function (...) {
    ...
  }
};

At core.js#L365, we would then instead just do Linearization.create(this.stream).

@yurydelendik
Copy link
Contributor

At core.js#L365, we would then instead just do Linearization.create(this.stream).

Yep. You may also make getInt and getHints as regular function. It is up to you to keep Linearization as pure static utility class or have class with only data fields. In both cases you will have create() method.

@Snuffleupagus
Copy link
Collaborator Author

@yurydelendik I've pushed an updated version that attempts to address your comments; please check if this is what you had in mind!

@yurydelendik
Copy link
Contributor

Yep. It looks good.

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/4a7cd41270d717d/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/72dd4f6d39f422c/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/4a7cd41270d717d/output.txt

Total script time: 21.12 mins

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

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/72dd4f6d39f422c/output.txt

Total script time: 22.88 mins

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

@yurydelendik
Copy link
Contributor

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/58fd885413430d0/output.txt

yurydelendik added a commit that referenced this pull request Jul 28, 2014
Re-factor parsing of the Linearization dictionary
@yurydelendik yurydelendik merged commit 2e47b58 into mozilla:master Jul 28, 2014
@yurydelendik
Copy link
Contributor

Thank you for the patch

@Snuffleupagus Snuffleupagus deleted the linearization-refactor branch July 28, 2014 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: "L" field in linearization table is invalid
3 participants