[libcxx-commits] [libcxx] cb15116 - [libc++] use more early returns for consistency

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


Author: Joerg Sonnenberger
Date: 2021-05-23T23:10:45+02:00
New Revision: cb1511645170ec23036631790398d8143a832265

URL: https://github.com/llvm/llvm-project/commit/cb1511645170ec23036631790398d8143a832265
DIFF: https://github.com/llvm/llvm-project/commit/cb1511645170ec23036631790398d8143a832265.diff

LOG: [libc++] use more early returns for consistency

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D96983

Added: 
    

Modified: 
    libcxx/src/filesystem/operations.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index e604cc6c57c0..99001a067933 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -1031,16 +1031,13 @@ bool __create_directory(const path& p, error_code* ec) {
   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;
 }
 


        


More information about the libcxx-commits mailing list