diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2018-01-04 13:46:22 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2018-01-04 13:46:22 +0000 |
commit | f7373fce65da8e99ad051481ba711756b69baa7e (patch) | |
tree | b3e7b090c35ae6ab20e8375e6a1ff25bf899bb32 | |
parent | c54af0682ce0881ecde74a3b7502287a53ced378 (diff) | |
download | gcc-f7373fce65da8e99ad051481ba711756b69baa7e.tar.gz |
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
-rw-r--r-- | libstdc++-v3/ChangeLog | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/fs_ops.h | 7 | ||||
-rw-r--r-- | 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 <jwakely@redhat.com> + * 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); |