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

util: Simplify SIMD setup #8579

Closed
wants to merge 2 commits into from
Closed

util: Simplify SIMD setup #8579

wants to merge 2 commits into from

Conversation

danyshaanan
Copy link
Contributor

@danyshaanan danyshaanan commented Sep 17, 2016

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • commit message follows commit guidelines
Description of change

Turned the SIMD setup into a loop, and without the typeof checks, in accordance with nodejs/code-and-learn#56 (comment)


if (typeof SIMD.Uint32x4 === 'function')
simdFormatters.set(SIMD.Uint32x4, make(SIMD.Uint32x4.extractLane, 4));
const countPerType = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would a Map be more useful here?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it would. This object is just here to be iterated on two lines below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A literal map, using the SIMD fields as keys?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah as in new Map()
@targos simdFormatters is kind of the same case so consistency(?) :P

Copy link
Contributor

Choose a reason for hiding this comment

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

Please just keep it as an Object.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍


if (typeof SIMD.Uint8x16 === 'function')
simdFormatters.set(SIMD.Uint8x16, make(SIMD.Uint8x16.extractLane, 16));
Object.keys(countPerType).forEach((key) => {
Copy link
Member

Choose a reason for hiding this comment

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

That can be simplified with a for..in loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On it.

@danyshaanan
Copy link
Contributor Author

danyshaanan commented Sep 17, 2016

At @targos's suggestion, replaced Object.keys().forEach with for..in.

I could squash the commits once the code will seem OK.

Copy link
Member

@targos targos left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@targos
Copy link
Member

targos commented Sep 17, 2016

@mscdex mscdex added the util Issues and PRs related to the built-in util module. label Sep 17, 2016
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@imyller imyller left a comment

Choose a reason for hiding this comment

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

LGTM

@addaleax
Copy link
Member

Landed in 5f29947, thanks for the contribution @danyshaanan!

@addaleax addaleax closed this Sep 20, 2016
addaleax pushed a commit that referenced this pull request Sep 20, 2016
PR-URL: #8579
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Fishrock123 pushed a commit that referenced this pull request Oct 11, 2016
PR-URL: #8579
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
@MylesBorins
Copy link
Contributor

Added the dont-land-on-v4.x label the original SIMD changes are not on the v4.x tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants