[libcxx-commits] [libcxx] a77e918 - libcxx: use early returns
Joerg Sonnenberger via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 18 10:43:46 PST 2021
Author: Joerg Sonnenberger
Date: 2021-02-18T19:43:14+01:00
New Revision: a77e918016043691246d61f045519aaa5bc200f5
URL: https://github.com/llvm/llvm-project/commit/a77e918016043691246d61f045519aaa5bc200f5
DIFF: https://github.com/llvm/llvm-project/commit/a77e918016043691246d61f045519aaa5bc200f5.diff
LOG: libcxx: use early returns
Differential Revision: https://reviews.llvm.org/D96955
Added:
Modified:
libcxx/src/filesystem/operations.cpp
Removed:
################################################################################
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index 88a039f85021..458ba1648a18 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -1051,7 +1051,7 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) {
StatT attr_stat;
error_code mec;
- auto st = detail::posix_stat(attributes, attr_stat, &mec);
+ file_status st = detail::posix_stat(attributes, attr_stat, &mec);
if (!status_known(st))
return err.report(mec);
if (!is_directory(st))
@@ -1061,16 +1061,14 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) {
if (detail::mkdir(p.c_str(), attr_stat.st_mode) == 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());
+
+ mec = capture_errno();
+ error_code ignored_ec;
+ st = status(p, ignored_ec);
+ if (!is_directory(st))
+ return err.report(mec);
return false;
}
More information about the libcxx-commits
mailing list