aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-08-27 10:59:54 +0100
committerJonathan Wakely <jwakely@redhat.com>2021-08-28 11:52:22 +0100
commit07b990ee23e0c7a92d362dbb25fd5d57d95eb8be (patch)
tree1fe12d17bfc1fce7e9d91aa7a6d16e8bb4eb8bc1
parent952095bb053cfef47b48cc4345d658b8d8829800 (diff)
downloadgcc-07b990ee23e0c7a92d362dbb25fd5d57d95eb8be.zip
gcc-07b990ee23e0c7a92d362dbb25fd5d57d95eb8be.tar.gz
gcc-07b990ee23e0c7a92d362dbb25fd5d57d95eb8be.tar.bz2
libstdc++: Fix inefficiency in filesystem::absolute [PR99876]
When the path is already absolute, the call to current_path() is wasteful, because operator/ will ignore the left operand anyway. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/99876 * src/c++17/fs_ops.cc (fs::absolute): Call non-throwing form, to avoid unnecessary current_path() call.
-rw-r--r--libstdc++-v3/src/c++17/fs_ops.cc7
1 files changed, 0 insertions, 7 deletions
diff --git a/libstdc++-v3/src/c++17/fs_ops.cc b/libstdc++-v3/src/c++17/fs_ops.cc
index 0e2d952..2eac997 100644
--- a/libstdc++-v3/src/c++17/fs_ops.cc
+++ b/libstdc++-v3/src/c++17/fs_ops.cc
@@ -65,19 +65,12 @@ namespace posix = std::filesystem::__gnu_posix;
fs::path
fs::absolute(const path& p)
{
-#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
error_code ec;
path ret = absolute(p, ec);
if (ec)
_GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot make absolute path", p,
ec));
return ret;
-#else
- if (p.empty())
- _GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot make absolute path", p,
- make_error_code(std::errc::invalid_argument)));
- return current_path() / p;
-#endif
}
fs::path