[Bug libstdc++/99876] std::filesystem::absolute is inefficient
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99876 Jonathan Wakely changed: What|Removed |Added Last reconfirmed|2021-04-01 00:00:00 |2021-8-28 Target Milestone|--- |10.4 Keywords||missed-optimization
[Bug libstdc++/99876] std::filesystem::absolute is inefficient
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99876 Jonathan Wakely changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Status|NEW |ASSIGNED
[Bug libstdc++/99876] std::filesystem::absolute is inefficient
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99876 --- Comment #3 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:07b990ee23e0c7a92d362dbb25fd5d57d95eb8be commit r12-3198-g07b990ee23e0c7a92d362dbb25fd5d57d95eb8be Author: Jonathan Wakely Date: Fri Aug 27 10:59:54 2021 +0100 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 libstdc++-v3/ChangeLog: PR libstdc++/99876 * src/c++17/fs_ops.cc (fs::absolute): Call non-throwing form, to avoid unnecessary current_path() call.
[Bug libstdc++/99876] std::filesystem::absolute is inefficient
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99876 --- Comment #4 from CVS Commits --- The releases/gcc-11 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:7df66a0c95a6b3678c73385969c1395a8aab2bd6 commit r11-9107-g7df66a0c95a6b3678c73385969c1395a8aab2bd6 Author: Jonathan Wakely Date: Fri Aug 27 10:59:54 2021 +0100 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 libstdc++-v3/ChangeLog: PR libstdc++/99876 * src/c++17/fs_ops.cc (fs::absolute): Call non-throwing form, to avoid unnecessary current_path() call. (cherry picked from commit 07b990ee23e0c7a92d362dbb25fd5d57d95eb8be)
[Bug libstdc++/99876] std::filesystem::absolute is inefficient
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99876 --- Comment #5 from CVS Commits --- The releases/gcc-10 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:154316697dbea9ba96bc14680b642b3ae35dadbd commit r10-10186-g154316697dbea9ba96bc14680b642b3ae35dadbd Author: Jonathan Wakely Date: Fri Aug 27 10:59:54 2021 +0100 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 libstdc++-v3/ChangeLog: PR libstdc++/99876 * src/c++17/fs_ops.cc (fs::absolute): Call non-throwing form, to avoid unnecessary current_path() call. (cherry picked from commit 07b990ee23e0c7a92d362dbb25fd5d57d95eb8be)
[Bug libstdc++/99876] std::filesystem::absolute is inefficient
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99876 Jonathan Wakely changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #6 from Jonathan Wakely --- Fixed for 10.4 and 11.3 now.
[Bug libstdc++/99876] std::filesystem::absolute is inefficient
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99876 Jonathan Wakely changed: What|Removed |Added Last reconfirmed||2021-04-01 Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely --- (In reply to M Welinder from comment #0) > If the given filename is already absolute, it should be simply returned. > There is no need to call current_path() which leads to a getcwd syscall. Yes we already do that for the overload with an error_code parameter: fs::path fs::absolute(const path& p, error_code& ec) { path ret; if (p.empty()) { ec = make_error_code(std::errc::invalid_argument); return ret; } ec.clear(); if (p.is_absolute()) { ret = p; return ret; }
[Bug libstdc++/99876] std::filesystem::absolute is inefficient
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99876 --- Comment #2 from Jonathan Wakely --- --- 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
[Bug libstdc++/99876] std::filesystem::absolute is inefficient
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99876 Jonathan Wakely changed: What|Removed |Added Status|ASSIGNED|NEW Assignee|redi at gcc dot gnu.org|unassigned at gcc dot gnu.org