From 32839c63cb26b24def8b14a0d74b6c4372a4f2d9 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Tue, 21 May 2024 21:45:35 -0400 Subject: [PATCH] src: reduce unnecessary `GetCwd` calls PR-URL: https://github.com/nodejs/node/pull/53064 Reviewed-By: Richard Lau Reviewed-By: Trivikram Kamat Reviewed-By: Benjamin Gruenbaum Reviewed-By: Luigi Pinca Reviewed-By: Rafael Gonzaga --- src/path.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/path.cc b/src/path.cc index 78dd5804fc391d..af9dae4071d794 100644 --- a/src/path.cc +++ b/src/path.cc @@ -240,8 +240,7 @@ std::string PathResolve(Environment* env, const size_t numArgs = paths.size(); for (int i = numArgs - 1; i >= -1 && !resolvedAbsolute; i--) { - const std::string& path = - (i >= 0) ? std::string(paths[i]) : env->GetCwd(env->exec_path()); + const std::string& path = (i >= 0) ? std::string(paths[i]) : cwd; if (!path.empty()) { resolvedPath = std::string(path) + "/" + resolvedPath;