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 Util.appendToArray and Util.prependToArray #9793

Merged
merged 1 commit into from
Jun 10, 2018

Conversation

timvandermeij
Copy link
Contributor

The former may be replaced by regular JavaScript array concatenation and the latter is unused. This avoids unnecessary function calls/imports.

@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@timvandermeij
Copy link
Contributor Author

/botio test

@Snuffleupagus
Copy link
Collaborator

This avoids unnecessary function calls/imports.

While that's certainly correct, it will however result in more allocations[1] since the existing array won't be re-used; please refer to this MDN article:

The concat() method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.


[1] Whether or not this would be a problem, I don't know. Using push instead of concat might work!?

The former may be replaced by regular JavaScript array concatenation and
the latter is unused. This avoids unnecessary function calls/imports.
@mozilla mozilla deleted a comment from pdfjsbot Jun 10, 2018
@mozilla mozilla deleted a comment from pdfjsbot Jun 10, 2018
@mozilla mozilla deleted a comment from pdfjsbot Jun 10, 2018
@mozilla mozilla deleted a comment from pdfjsbot Jun 10, 2018
@mozilla mozilla deleted a comment from pdfjsbot Jun 10, 2018
@mozilla mozilla deleted a comment from pdfjsbot Jun 10, 2018
@timvandermeij
Copy link
Contributor Author

Good point! With the spread syntax, it's now possible to use the regular push operation instead of concat, so this both avoids additional method calls and reuses the original array. I have pushed the new version. Could you check if it's what you had in mind?

@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/c2a283c1d4a601f/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/c2a283c1d4a601f/output.txt

Total script time: 3.00 mins

Published

@timvandermeij
Copy link
Contributor Author

/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/da0a4bd7e532796/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/4e61f19347b2287/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/da0a4bd7e532796/output.txt

Total script time: 19.13 mins

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/4e61f19347b2287/output.txt

Total script time: 23.23 mins

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

@Snuffleupagus
Copy link
Collaborator

Could you check if it's what you had in mind?

That looks great; and it's nice that more (old) code can be removed now!


A good follow-up might be to try and replace Util.extendObj with (the native) Object.assign too. It'd basically just be a search-and-replace exercise, but you'd probably need to add a (core-js) polyfill though.

@timvandermeij timvandermeij merged commit 0e0fa48 into mozilla:master Jun 10, 2018
@timvandermeij timvandermeij deleted the refactoring branch June 10, 2018 14:14
@timvandermeij
Copy link
Contributor Author

Thank you for checking this!

movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Remove `Util.appendToArray` and `Util.prependToArray`
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