forked from qt-creator/qt-creator
Utils: Optimize Small String comparison a little bit
Change-Id: I798d4c399b1aced566e9b302463fd6491c04e8a1 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -673,23 +673,15 @@ bool operator==(Type first, const SmallString& second) noexcept
|
|||||||
inline
|
inline
|
||||||
bool operator==(const SmallString& first, const SmallString& second) noexcept
|
bool operator==(const SmallString& first, const SmallString& second) noexcept
|
||||||
{
|
{
|
||||||
if (Q_LIKELY(first.size() != second.size()))
|
return first.size() == second.size()
|
||||||
return false;
|
&& std::memcmp(first.data(), second.data(), first.size()) == 0;
|
||||||
|
|
||||||
const int comparison = std::memcmp(first.data(), second.data(), first.size());
|
|
||||||
|
|
||||||
return comparison == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool operator==(const SmallString& first, const SmallStringView& second) noexcept
|
bool operator==(const SmallString& first, const SmallStringView& second) noexcept
|
||||||
{
|
{
|
||||||
if (Q_LIKELY(first.size() != second.size()))
|
return first.size() == second.size()
|
||||||
return false;
|
&& std::memcmp(first.data(), second.data(), first.size()) == 0;
|
||||||
|
|
||||||
const int comparison = std::memcmp(first.data(), second.data(), first.size());
|
|
||||||
|
|
||||||
return comparison == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|||||||
Reference in New Issue
Block a user