From f48be4b7d126de9023b75146671a86511aea9119 Mon Sep 17 00:00:00 2001 From: redi Date: Thu, 4 Jan 2018 13:46:22 +0000 Subject: [PATCH] Avoid redundant calls to filesystem::status_known * include/bits/fs_ops.h (exists(const path&, error_code&))): Only check status_known once. * include/experimental/bits/fs_ops.h: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@256243 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 4 ++++ libstdc++-v3/include/bits/fs_ops.h | 7 +++++-- libstdc++-v3/include/experimental/bits/fs_ops.h | 7 +++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1fca54f212d..83361d45188 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2018-01-04 Jonathan Wakely + * include/bits/fs_ops.h (exists(const path&, error_code&))): Only + check status_known once. + * include/experimental/bits/fs_ops.h: Likewise. + PR libstdc++/83607 * include/std/functional (__is_byte_like): New trait. (__is_std_equal_to): Remove. diff --git a/libstdc++-v3/include/bits/fs_ops.h b/libstdc++-v3/include/bits/fs_ops.h index 3c63adefca7..e61a1236bec 100644 --- a/libstdc++-v3/include/bits/fs_ops.h +++ b/libstdc++-v3/include/bits/fs_ops.h @@ -125,8 +125,11 @@ namespace filesystem { auto __s = status(__p, __ec); if (status_known(__s)) - __ec.clear(); - return exists(__s); + { + __ec.clear(); + return __s.type() != file_type::not_found; + } + return false; } uintmax_t file_size(const path& __p); diff --git a/libstdc++-v3/include/experimental/bits/fs_ops.h b/libstdc++-v3/include/experimental/bits/fs_ops.h index e36291195bb..45192b1b34a 100644 --- a/libstdc++-v3/include/experimental/bits/fs_ops.h +++ b/libstdc++-v3/include/experimental/bits/fs_ops.h @@ -131,8 +131,11 @@ inline namespace v1 { auto __s = status(__p, __ec); if (status_known(__s)) - __ec.clear(); - return exists(__s); + { + __ec.clear(); + return __s.type() != file_type::not_found; + } + return false; } uintmax_t file_size(const path& __p); -- 2.11.4.GIT