path: refactor logic for to reduce code branches

This refactoring makes sure some code branches will not be hit if
they do not have to be reached.

PR-URL: https://github.com/nodejs/node/pull/25278
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
Ruben Bridgewater 2019-01-27 15:27:28 +01:00
parent f59fdd9d65
commit e750e9583e
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -224,23 +224,25 @@ const win32 = {
isAbsolute = true; isAbsolute = true;
} }
if (device.length > 0 && if (device.length > 0) {
resolvedDevice.length > 0 && if (resolvedDevice.length > 0) {
device.toLowerCase() !== resolvedDevice.toLowerCase()) { if (device.toLowerCase() !== resolvedDevice.toLowerCase())
// This path points to another device so it is not applicable // This path points to another device so it is not applicable
continue; continue;
} else {
resolvedDevice = device;
}
} }
if (resolvedDevice.length === 0 && device.length > 0) { if (resolvedAbsolute) {
resolvedDevice = device; if (resolvedDevice.length > 0)
} break;
if (!resolvedAbsolute) { } else {
resolvedTail = path.slice(rootEnd) + '\\' + resolvedTail; resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
resolvedAbsolute = isAbsolute; resolvedAbsolute = isAbsolute;
} if (isAbsolute && resolvedDevice.length > 0) {
break;
if (resolvedDevice.length > 0 && resolvedAbsolute) { }
break;
} }
} }