Skip to content

Commit

Permalink
process: simplify check in previousValueIsValid()
Browse files Browse the repository at this point in the history
This commit replaces a call to Number.isFinite() with a
cheaper typeof check. The subsequent range checks ensure that
the checked value is finite.

PR-URL: #24836
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
cjihrig authored and BethGriggs committed Feb 12, 2019
1 parent 520d041 commit fd8a481
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/process/per_thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function setupCpuUsage(_cpuUsage) {
// Ensure that a previously passed in value is valid. Currently, the native
// implementation always returns numbers <= Number.MAX_SAFE_INTEGER.
function previousValueIsValid(num) {
return Number.isFinite(num) &&
return typeof num === 'number' &&
num <= Number.MAX_SAFE_INTEGER &&
num >= 0;
}
Expand Down

0 comments on commit fd8a481

Please sign in to comment.