Skip to content

util: use ES2015+ Object.is to check negative zero#11332

Closed
shinnn wants to merge 1 commit into
nodejs:masterfrom
shinnn:object-is
Closed

util: use ES2015+ Object.is to check negative zero#11332
shinnn wants to merge 1 commit into
nodejs:masterfrom
shinnn:object-is

Conversation

@shinnn

@shinnn shinnn commented Feb 13, 2017

Copy link
Copy Markdown
Contributor

The original code is written in 2013. Today we can use more simple way Object.is, which was introduced in ECMAScript 6, to check whether the value is negative zero or not.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

util

@nodejs-github-bot nodejs-github-bot added the util Issues and PRs related to the built-in util module. label Feb 13, 2017
Comment thread lib/util.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The removal of this line leaves the sentence from the previous line incomplete.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I missed the last comma (not a period) in the previous line.

The original code nodejs@b3e4fc6 is written in 2013. Today we can use more simple way `Object.is`, which was introduced in ECMAScript 6, to check whether the value is negative zero or not.

@bnoordhuis bnoordhuis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bnoordhuis

Copy link
Copy Markdown
Member

@shinnn By the way, did you check that the benchmarks in benchmark/util didn't regress?

@shinnn

shinnn commented Feb 13, 2017

Copy link
Copy Markdown
Contributor Author

did you check that the benchmarks in benchmark/util didn't regress?

On my machine,

# before
util/inspect.js n=5000000: 34,926.911787501784

# after
util/inspect.js n=5000000: 34,675.27026138018

However, I guess this change doesn't actually affect the existing util.inspect benchmark because the test fixture doesn't include any numbers.

util.inspect({a: 'a', b: 'b', c: 'c', d: 'd'});

@evanlucas evanlucas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM and test/parallel/test-util-inspect.js already has a test for this. Thanks!

jasnell pushed a commit that referenced this pull request Feb 16, 2017
Use `Object.is` to check whether the value is negative zero or not.

Ref: b3e4fc6
PR-URL: #11332
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@jasnell

jasnell commented Feb 16, 2017

Copy link
Copy Markdown
Member

Landed in 5ddf722

@jasnell jasnell closed this Feb 16, 2017
italoacasas pushed a commit to italoacasas/node that referenced this pull request Feb 20, 2017
Use `Object.is` to check whether the value is negative zero or not.

Ref: nodejs@b3e4fc6
PR-URL: nodejs#11332
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
italoacasas pushed a commit that referenced this pull request Feb 22, 2017
Use `Object.is` to check whether the value is negative zero or not.

Ref: b3e4fc6
PR-URL: #11332
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@italoacasas italoacasas mentioned this pull request Feb 25, 2017
@jasnell

jasnell commented Mar 7, 2017

Copy link
Copy Markdown
Member

This would need a backport PR to land in v4

jasnell pushed a commit that referenced this pull request Mar 7, 2017
Use `Object.is` to check whether the value is negative zero or not.

Ref: b3e4fc6
PR-URL: #11332
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
MylesBorins pushed a commit that referenced this pull request Mar 9, 2017
Use `Object.is` to check whether the value is negative zero or not.

Ref: b3e4fc6
PR-URL: #11332
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Mar 9, 2017
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.