Skip to content

Commit 83e2c46

Browse files
committed
fs: refactor namespaced drive root check for performance
1 parent c97462b commit 83e2c46

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/node_file.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,12 +2018,14 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
20182018
if (processed_path.length() == 3 && std::isalpha(processed_path[0]) &&
20192019
processed_path[1] == ':' && processed_path[2] == '\\') {
20202020
is_drive_root = true;
2021-
} else if (processed_path.length() >= 6 &&
2022-
processed_path.substr(0, 4) == "\\\\?\\" &&
2023-
processed_path.length() >= 7 &&
2024-
std::isalpha(processed_path[4]) && processed_path[5] == ':' &&
2025-
processed_path[6] == '\\' &&
2026-
(processed_path.length() == 7 || processed_path[7] == '\0')) {
2021+
} else if (processed_path.length() == 7 &&
2022+
processed_path[0] == '\\' &&
2023+
processed_path[1] == '\\' &&
2024+
processed_path[2] == '?' &&
2025+
processed_path[3] == '\\' &&
2026+
std::isalpha(processed_path[4]) &&
2027+
processed_path[5] == ':' &&
2028+
processed_path[6] == '\\') {
20272029
is_drive_root = true;
20282030
}
20292031
}

0 commit comments

Comments
 (0)