* [committed] libstdc++: Fix inefficiency in filesystem::absolute [PR99876]
@ 2021-08-28 12:15 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-08-28 12:15 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 425 bytes --]
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.
Tested powerpc64le-linux. Committed to trunk.
I'll backport to gcc-10 and gcc-11 too.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1319 bytes --]
commit 07b990ee23e0c7a92d362dbb25fd5d57d95eb8be
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Aug 27 10:59:54 2021
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.
diff --git a/libstdc++-v3/src/c++17/fs_ops.cc b/libstdc++-v3/src/c++17/fs_ops.cc
index 0e2d952673f..2eac9977785 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-28 12:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-28 12:15 [committed] libstdc++: Fix inefficiency in filesystem::absolute [PR99876] Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).