From c738b73bcf7bd8f4eba4b2f4b8ff1c421a6896d4 Mon Sep 17 00:00:00 2001 From: Voltrex <62040526+VoltrexMaster@users.noreply.github.com> Date: Mon, 10 May 2021 01:24:43 +0430 Subject: [PATCH] path: inline conditions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This condition can be inlined in the first `if` statement since if the `path`'s length is 0, it'll be a empty string so we can return that as there's no need for an extra `if` statement. PR-URL: https://github.com/nodejs/node/pull/38613 Reviewed-By: James M Snell Reviewed-By: Michaƫl Zasso Reviewed-By: Richard Lau Reviewed-By: Darshan Sen Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott --- lib/path.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/path.js b/lib/path.js index 079177694dc65c..e9f3adec9ef394 100644 --- a/lib/path.js +++ b/lib/path.js @@ -608,13 +608,9 @@ const win32 = { toNamespacedPath(path) { // Note: this will *probably* throw somewhere. - if (typeof path !== 'string') + if (typeof path !== 'string' || path.length === 0) return path; - if (path.length === 0) { - return ''; - } - const resolvedPath = win32.resolve(path); if (resolvedPath.length <= 2)