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

Remove the unused defaultColor property on ColorSpace instances #10000

Merged

Conversation

Snuffleupagus
Copy link
Collaborator

This property is not only completely unused now, it never actually appears to have been used. Even though the memory savings, from not initializing these extra typed arrays, won't be significant in the grand scheme of things it still seems completely unnecessary to keep allocating this data.

As far as I can tell, the main reason for the existence of defaultColor seem to be for documentation purposes. Hence the code is changed into comments instead, to keep the information around (but without the unnecessary allocations).

@timvandermeij
Copy link
Contributor

timvandermeij commented Aug 22, 2018

I think converting this to textual comments instead of code comments would be better, i.e., something like // The default color is black.. It's not only more readable, but it also prevents people from throwing it away later since now it looks like unused commented-out code instead of documentation. Would you agree?

@Snuffleupagus
Copy link
Collaborator Author

Snuffleupagus commented Aug 22, 2018

I think converting this to textual comments instead of code comments would be better, i.e., something like // The default color is black.

That sounds really simple, until you start looking at either the AlternateCS or DeviceCmykCS cases :-(

It's not only more readable,

In either of those cases, trying to explain things with a "regular" comment is going to be a lot less clear not to mention longer.
The easiest solution would of course be to simply throw out the comments completely, since they've never been used. Another, perhaps better, option could be to append something like The default color is {insert typed array here}. comments to existing JSDocs such as e.g. https://github.com/mozilla/pdf.js/blob/master/src/core/colorspace.js#L419-L424.

This property is not only completely unused now, it never actually appears to have been used. Even though the memory savings, from not initializing these extra typed arrays, won't be significant in the grand scheme of things it still seems completely unnecessary to keep allocating this data.

As far as I can tell, the main reason for the existence of `defaultColor` seem to be for documentation purposes. Hence the code is changed into comments instead, to keep the information around (but without the unnecessary allocations).
@timvandermeij
Copy link
Contributor

Looks better this way. Let's see how it goes.

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/06fb61962a3e007/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/8be3cbc3187c885/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/8be3cbc3187c885/output.txt

Total script time: 24.70 mins

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

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/06fb61962a3e007/output.txt

Total script time: 57.77 mins

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

@timvandermeij timvandermeij merged commit 32d02c5 into mozilla:master Aug 24, 2018
@timvandermeij
Copy link
Contributor

Nice optimization!

@Snuffleupagus Snuffleupagus deleted the rm-ColorSpace-defaultColor branch August 24, 2018 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants