Skip to content

Commit 8b109f0

Browse files
cjihrigMylesBorins
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 <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>
1 parent a5c5786 commit 8b109f0

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)