★ wanayoo — archive 1999 https://github.com/nodejs/node/pull/17507Nouvelle recherche | Portail wanayoo
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: fix negative 0 check in inspect #17507

Closed
wants to merge 1 commit into from
Closed

Conversation

devsnek
Copy link
Member

@devsnek devsnek commented Dec 6, 2017

closes #17500

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

util

refack
refack approved these changes Dec 6, 2017
lib/util.js Outdated
@@ -600,7 +600,7 @@ function formatNumber(fn, value) {
// Format -0 as '-0'. A `value === -0` check won't distinguish 0 from -0.
// Using a division check is currently faster than `Object.is(value, -0)`
// as of V8 6.1.
if (1 / value === -Infinity)
if (value === 0 && 1 / value === -Infinity)
Copy link
Member

@bnoordhuis bnoordhuis Dec 6, 2017

Choose a reason for hiding this comment

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

if (Object.is(value, -0))

Copy link
Member

@apapirovski apapirovski Dec 6, 2017

Choose a reason for hiding this comment

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

The performance concern is real (3x slower for Object.is) but does it really matter in this case? It feels like this might be a micro-optimization too far.

Copy link
Member

@bnoordhuis bnoordhuis Dec 6, 2017

Choose a reason for hiding this comment

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

It got better recently but those changes may not be in 6.3 yet. And yeah, I don't think Object.is() is going to be the expensive part here.

lib/util.js Outdated
@@ -600,7 +600,7 @@ function formatNumber(fn, value) {
// Format -0 as '-0'. A `value === -0` check won't distinguish 0 from -0.
// Using a division check is currently faster than `Object.is(value, -0)`
// as of V8 6.1.
Copy link
Member

@apapirovski apapirovski Dec 6, 2017

Choose a reason for hiding this comment

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

The comment should be adjusted if this is being changed to Object.is again.

lib/util.js Outdated
// Using a division check is currently faster than `Object.is(value, -0)`
// as of V8 6.1.
// `Object.is` is faster as of 6.3, and this code doesn't
// need to be very performant anyway
Copy link
Member

@apapirovski apapirovski Dec 6, 2017

Choose a reason for hiding this comment

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

Sorry, I was thinking something more along the lines of:

// Format -0 as '-0'. A `value === -0` check won't distinguish 0 from -0.

We don't really need to talk about the performance of it, IMHO.

Copy link
Member Author

@devsnek devsnek Dec 6, 2017

Choose a reason for hiding this comment

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

alright 😄

cjihrig
cjihrig approved these changes Dec 7, 2017
lpinca
lpinca approved these changes Dec 7, 2017
Copy link
Member

@BridgeAR BridgeAR left a comment

LGTM but we definitely should add a test before landing.

@apapirovski
Copy link
Member

@apapirovski apapirovski commented Dec 8, 2017

@BridgeAR would you mind reviewing this? It appears your feedback might've been addressed. Thank you!

@addaleax
Copy link
Member

@addaleax addaleax commented Dec 8, 2017

refack
refack approved these changes Dec 8, 2017
@apapirovski
Copy link
Member

@apapirovski apapirovski commented Dec 9, 2017

Landed in 86527bd

@apapirovski apapirovski closed this Dec 9, 2017
apapirovski added a commit that referenced this issue Dec 9, 2017
PR-URL: #17507
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@devsnek devsnek deleted the patch-6 branch Dec 9, 2017
MylesBorins added a commit that referenced this issue Dec 12, 2017
PR-URL: #17507
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
MylesBorins added a commit that referenced this issue Dec 12, 2017
PR-URL: #17507
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@MylesBorins MylesBorins mentioned this pull request Dec 12, 2017
@gibfahn
Copy link
Member

@gibfahn gibfahn commented Dec 20, 2017

Should this be backported to v6.x-staging? If yes please follow the guide and raise a backport PR, if no let me know or add the dont-land-on label.

gibfahn added a commit that referenced this issue Dec 20, 2017
PR-URL: #17507
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@gibfahn gibfahn mentioned this pull request Dec 20, 2017
gibfahn added a commit that referenced this issue Dec 20, 2017
PR-URL: #17507
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@gibfahn gibfahn mentioned this pull request Dec 20, 2017
@devsnek devsnek mentioned this pull request Dec 29, 2018
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.