Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
cjihrig committed Dec 4, 2018
commit 9dd8c2dce60151ccf1ce6b1bbc4b4cd8ed73d1a3
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