From 9dd8c2dce60151ccf1ce6b1bbc4b4cd8ed73d1a3 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Tue, 4 Dec 2018 16:49:03 -0500 Subject: [PATCH] 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. --- lib/internal/process/per_thread.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 952abda8b67147..ad634b757eca48 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -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; }