diff --git a/src/libs/utils/smallstring.h b/src/libs/utils/smallstring.h index 403155eb66e..aeeeeb98506 100644 --- a/src/libs/utils/smallstring.h +++ b/src/libs/utils/smallstring.h @@ -670,22 +670,14 @@ public: friend bool operator<(const BasicSmallString& first, SmallStringView second) noexcept { - if (first.size() != second.size()) - return first.size() < second.size(); - - const int comparison = std::memcmp(first.data(), second.data(), first.size()); - - return comparison < 0; + return first.size() < second.size() + || (first.size() == second.size() && std::memcmp(first.data(), second.data(), first.size()) < 0); } friend bool operator<(SmallStringView first, const BasicSmallString& second) noexcept { - if (first.size() != second.size()) - return first.size() < second.size(); - - const int comparison = std::memcmp(first.data(), second.data(), first.size()); - - return comparison < 0; + return first.size() < second.size() + || (first.size() == second.size() && std::memcmp(first.data(), second.data(), first.size()) < 0); } friend BasicSmallString operator+(const BasicSmallString &first, const BasicSmallString &second) @@ -987,12 +979,8 @@ template class String, || isSameString::value>> bool operator<(const String &first, const String &second) noexcept { - if (first.size() != second.size()) - return first.size() < second.size(); - - const int comparison = std::memcmp(first.data(), second.data(), first.size() + 1); - - return comparison < 0; + return first.size() < second.size() + || (first.size() == second.size() && std::memcmp(first.data(), second.data(), first.size()) < 0); } template