From: Jonathan Wakely Date: Thu, 4 Jan 2018 13:46:22 +0000 (+0000) Subject: Avoid redundant calls to filesystem::status_known X-Git-Tag: basepoints/gcc-9~2232 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f7373fce65da8e99ad051481ba711756b69baa7e;p=thirdparty%2Fgcc.git 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1fca54f212df..83361d45188c 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 3c63adefca79..e61a1236becc 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 e36291195bb0..45192b1b34a8 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);