From 640d12691729d3b3596885f8c56c4bd7cb4d849c Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 25 Feb 2016 13:45:09 +0100 Subject: [PATCH] Utils: Optimize Small String comparison a little bit Change-Id: I798d4c399b1aced566e9b302463fd6491c04e8a1 Reviewed-by: Tobias Hunger --- src/libs/utils/smallstring.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/libs/utils/smallstring.h b/src/libs/utils/smallstring.h index 05eb93c0584..fedb2846a57 100644 --- a/src/libs/utils/smallstring.h +++ b/src/libs/utils/smallstring.h @@ -673,23 +673,15 @@ bool operator==(Type first, const SmallString& second) noexcept inline bool operator==(const SmallString& first, const SmallString& second) noexcept { - if (Q_LIKELY(first.size() != second.size())) - return false; - - const int comparison = std::memcmp(first.data(), second.data(), first.size()); - - return comparison == 0; + return first.size() == second.size() + && std::memcmp(first.data(), second.data(), first.size()) == 0; } inline bool operator==(const SmallString& first, const SmallStringView& second) noexcept { - if (Q_LIKELY(first.size() != second.size())) - return false; - - const int comparison = std::memcmp(first.data(), second.data(), first.size()); - - return comparison == 0; + return first.size() == second.size() + && std::memcmp(first.data(), second.data(), first.size()) == 0; } inline