From b089bf460b08af7ec482773366d65c422da66866 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 10 May 2024 23:54:22 -0500 Subject: [PATCH] [ox/std] Optimize Array compare --- deps/ox/src/ox/std/array.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/deps/ox/src/ox/std/array.hpp b/deps/ox/src/ox/std/array.hpp index d20a6180a..242010f1a 100644 --- a/deps/ox/src/ox/std/array.hpp +++ b/deps/ox/src/ox/std/array.hpp @@ -137,12 +137,16 @@ constexpr Array::Array(Array &&other) noexcept { template constexpr bool Array::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