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
This commit is contained in:
Jonathan Wakely 2018-01-04 13:46:22 +00:00 committed by Jonathan Wakely
parent c54af0682c
commit f7373fce65
3 changed files with 14 additions and 4 deletions

View File

@ -1,5 +1,9 @@
2018-01-04 Jonathan Wakely <jwakely@redhat.com> 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 PR libstdc++/83607
* include/std/functional (__is_byte_like): New trait. * include/std/functional (__is_byte_like): New trait.
(__is_std_equal_to): Remove. (__is_std_equal_to): Remove.

View File

@ -125,8 +125,11 @@ namespace filesystem
{ {
auto __s = status(__p, __ec); auto __s = status(__p, __ec);
if (status_known(__s)) 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); uintmax_t file_size(const path& __p);

View File

@ -131,8 +131,11 @@ inline namespace v1
{ {
auto __s = status(__p, __ec); auto __s = status(__p, __ec);
if (status_known(__s)) 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); uintmax_t file_size(const path& __p);