From fd8a481a129570141ac97985ca9115473d250385 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() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/pull/24836 Reviewed-By: Ben Noordhuis Reviewed-By: Ruben Bridgewater Reviewed-By: Jeremiah Senkpiel Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso --- 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 28f1881d6f7150..b196e4270f69b7 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; }