[libcxx-commits] [PATCH] D96983: [libc++] use more early returns for consistency

Joerg Sonnenberger via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun May 23 14:11:34 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb1511645170: [libc++] use more early returns for consistency (authored by joerg).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96983/new/

https://reviews.llvm.org/D96983

Files:
  libcxx/src/filesystem/operations.cpp


Index: libcxx/src/filesystem/operations.cpp
===================================================================
--- libcxx/src/filesystem/operations.cpp
+++ libcxx/src/filesystem/operations.cpp
@@ -1031,16 +1031,13 @@
   if (detail::mkdir(p.c_str(), static_cast<int>(perms::all)) == 0)
     return true;
 
-  if (errno == EEXIST) {
-    error_code mec = capture_errno();
-    error_code ignored_ec;
-    const file_status st = status(p, ignored_ec);
-    if (!is_directory(st)) {
-      err.report(mec);
-    }
-  } else {
-    err.report(capture_errno());
-  }
+  if (errno != EEXIST)
+    return err.report(capture_errno());
+  error_code mec = capture_errno();
+  error_code ignored_ec;
+  const file_status st = status(p, ignored_ec);
+  if (!is_directory(st))
+    return err.report(mec);
   return false;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96983.347270.patch
Type: text/x-patch
Size: 816 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210523/2a1bbebc/attachment.bin>


More information about the libcxx-commits mailing list