Avoid redundant calls to filesystem::status_known
authorJonathan Wakely <jwakely@redhat.com>
Thu, 4 Jan 2018 13:46:22 +0000 (13:46 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 4 Jan 2018 13:46:22 +0000 (13:46 +0000)
* 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
libstdc++-v3/include/bits/fs_ops.h
libstdc++-v3/include/experimental/bits/fs_ops.h

index 1fca54f212df7ea9daa2335dcd8bcc0a0653178c..83361d45188c397bb12dded20cbf8db886ed185f 100644 (file)
@@ -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.
index 3c63adefca7951c2c6b0bba5c762294affb7cdab..e61a1236becc1942373d3213810d07bf9dcea0ba 100644 (file)
@@ -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);
index e36291195bb0d71c2be6b1d7aab8de2f55505b66..45192b1b34a8123a6d7599679029f9784630422e 100644 (file)
@@ -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);