expected.h - fix bugprone-branch-clone warning
Fixes: system/core/base/include/android-base/expected.h:606:39: warning: repeated branch in conditional chain [bugprone-branch-clone] if (x.has_value() != y.has_value()) { ^ system/core/base/include/android-base/expected.h:608:4: note: end of the original } else if (!x.has_value()) { ^ system/core/base/include/android-base/expected.h:610:10: note: clone 1 starts here } else { ^ Test: builds Bug: 153035880 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ie67a8bb1bf622319adea15466c42077e0e9b1a18 Merged-In: Ie67a8bb1bf622319adea15466c42077e0e9b1a18
This commit is contained in:
parent
6d99e68e74
commit
ffaa7d6751
|
@ -387,13 +387,9 @@ class _NODISCARD_ expected {
|
|||
|
||||
template<class T1, class E1, class T2, class E2>
|
||||
constexpr bool operator==(const expected<T1, E1>& x, const expected<T2, E2>& y) {
|
||||
if (x.has_value() != y.has_value()) {
|
||||
return false;
|
||||
} else if (!x.has_value()) {
|
||||
return x.error() == y.error();
|
||||
} else {
|
||||
return *x == *y;
|
||||
}
|
||||
if (x.has_value() != y.has_value()) return false;
|
||||
if (!x.has_value()) return x.error() == y.error();
|
||||
return *x == *y;
|
||||
}
|
||||
|
||||
template<class T1, class E1, class T2, class E2>
|
||||
|
@ -581,35 +577,23 @@ class _NODISCARD_ expected<void, E> {
|
|||
|
||||
template<class E1, class E2>
|
||||
constexpr bool operator==(const expected<void, E1>& x, const expected<void, E2>& y) {
|
||||
if (x.has_value() != y.has_value()) {
|
||||
return false;
|
||||
} else if (!x.has_value()) {
|
||||
return x.error() == y.error();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
if (x.has_value() != y.has_value()) return false;
|
||||
if (!x.has_value()) return x.error() == y.error();
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T1, class E1, class E2>
|
||||
constexpr bool operator==(const expected<T1, E1>& x, const expected<void, E2>& y) {
|
||||
if (x.has_value() != y.has_value()) {
|
||||
return false;
|
||||
} else if (!x.has_value()) {
|
||||
return x.error() == y.error();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (x.has_value() != y.has_value()) return false;
|
||||
if (!x.has_value()) return x.error() == y.error();
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class E1, class T2, class E2>
|
||||
constexpr bool operator==(const expected<void, E1>& x, const expected<T2, E2>& y) {
|
||||
if (x.has_value() != y.has_value()) {
|
||||
return false;
|
||||
} else if (!x.has_value()) {
|
||||
return x.error() == y.error();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (x.has_value() != y.has_value()) return false;
|
||||
if (!x.has_value()) return x.error() == y.error();
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class E>
|
||||
|
|
Loading…
Reference in New Issue