util: use ES2015+ Object.is to check negative zero#11332
util: use ES2015+ Object.is to check negative zero#11332shinnn wants to merge 1 commit intonodejs:masterfrom
Conversation
lib/util.js
Outdated
There was a problem hiding this comment.
The removal of this line leaves the sentence from the previous line incomplete.
There was a problem hiding this comment.
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.
|
@shinnn By the way, 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.27026138018However, I guess this change doesn't actually affect the existing node/benchmark/util/inspect.js Line 13 in dcfda10 |
evanlucas
left a comment
There was a problem hiding this comment.
LGTM and test/parallel/test-util-inspect.js already has a test for this. Thanks!
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>
|
Landed in 5ddf722 |
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>
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>
|
This would need a backport PR to land in v4 |
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>
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>
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), orvcbuild test(Windows) passesAffected core subsystem(s)
util