[ox/std] Optimize Array compare
This commit is contained in:
parent
cd60c4abaf
commit
b089bf460b
12
deps/ox/src/ox/std/array.hpp
vendored
12
deps/ox/src/ox/std/array.hpp
vendored
@ -137,12 +137,16 @@ constexpr Array<T, ArraySize>::Array(Array &&other) noexcept {
|
||||
|
||||
template<typename T, std::size_t ArraySize>
|
||||
constexpr bool Array<T, ArraySize>::operator==(const Array &other) const {
|
||||
for (std::size_t i = 0; i < ArraySize; i++) {
|
||||
if (!(m_items[i] == other.m_items[i])) {
|
||||
return false;
|
||||
if (std::is_constant_evaluated()) {
|
||||
for (std::size_t i = 0; i < ArraySize; i++) {
|
||||
if (!(m_items[i] == other.m_items[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return memcmp(this, &other, sizeof(*this)) == 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T, std::size_t ArraySize>
|
||||
|
Loading…
Reference in New Issue
Block a user