Skip to content

Commit fd8a481

Browse files
cjihrigBethGriggs
authored andcommitted
process: simplify check in previousValueIsValid()
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]>
1 parent 520d041 commit fd8a481

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/process/per_thread.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function setupCpuUsage(_cpuUsage) {
8585
// Ensure that a previously passed in value is valid. Currently, the native
8686
// implementation always returns numbers <= Number.MAX_SAFE_INTEGER.
8787
function previousValueIsValid(num) {
88-
return Number.isFinite(num) &&
88+
return typeof num === 'number' &&
8989
num <= Number.MAX_SAFE_INTEGER &&
9090
num >= 0;
9191
}

0 commit comments

Comments
 (0)