From f7373fce65da8e99ad051481ba711756b69baa7e Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 4 Jan 2018 13:46:22 +0000 Subject: 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. From-SVN: r256243 --- 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(-) (limited to 'libstdc++-v3') 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); -- cgit v1.2.1