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 <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
cjihrig authored and BethGriggs committed Feb 20, 2019
1 parent 9e9e423 commit 00d0e92
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 00d0e92

Please sign in to comment.