Skip to content

Commit 2fb136e

Browse files
author
nullccxsy
committed
refactor: simplify ICEBERG_RETURN_UNEXPECTED macro implementation
- Streamlined the macro to reduce nesting and improve readability by using an inline if statement.
1 parent 3ef372a commit 2fb136e

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/iceberg/util/macros.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919

2020
#pragma once
2121

22-
#define ICEBERG_RETURN_UNEXPECTED(result) \
23-
do { \
24-
auto&& result_name = (result); \
25-
if (!result_name) [[unlikely]] { \
26-
return std::unexpected<Error>(result_name.error()); \
27-
} \
28-
} while (false);
22+
#define ICEBERG_RETURN_UNEXPECTED(result) \
23+
if (auto&& result_name = result; !result_name) [[unlikely]] { \
24+
return std::unexpected<Error>(result_name.error()); \
25+
}
2926

3027
#define ICEBERG_ASSIGN_OR_RAISE_IMPL(result_name, lhs, rexpr) \
3128
auto&& result_name = (rexpr); \

0 commit comments

Comments
 (0)