Fix comparing String with StringView

This commit is contained in:
Wojtek Figat
2020-12-31 16:55:42 +01:00
parent 3877f100c3
commit 66e8560b51
2 changed files with 8 additions and 8 deletions

View File

@@ -45,12 +45,12 @@ StringAnsi StringView::ToStringAnsi() const
bool operator==(const String& a, const StringView& b)
{
return StringUtils::Compare(a.GetText(), b.GetText()) == 0;
return a.Length() == b.Length() && StringUtils::Compare(a.GetText(), b.GetText(), b.Length()) == 0;
}
bool operator!=(const String& a, const StringView& b)
{
return StringUtils::Compare(a.GetText(), b.GetText()) != 0;
return a.Length() != b.Length() || StringUtils::Compare(a.GetText(), b.GetText(), b.Length()) != 0;
}
StringAnsiView StringAnsiView::Empty;
@@ -95,10 +95,10 @@ StringAnsi StringAnsiView::ToStringAnsi() const
bool operator==(const StringAnsi& a, const StringAnsiView& b)
{
return StringUtils::Compare(a.GetText(), b.GetText()) == 0;
return a.Length() == b.Length() && StringUtils::Compare(a.GetText(), b.GetText(), b.Length()) == 0;
}
bool operator!=(const StringAnsi& a, const StringAnsiView& b)
{
return StringUtils::Compare(a.GetText(), b.GetText()) != 0;
return a.Length() != b.Length() || StringUtils::Compare(a.GetText(), b.GetText(), b.Length()) != 0;
}

View File

@@ -347,8 +347,8 @@ inline uint32 GetHash(const StringView& key)
return StringUtils::GetHashCode(key.Get(), key.Length());
}
bool operator==(const String& a, const StringView& b);
bool operator!=(const String& a, const StringView& b);
bool FLAXENGINE_API operator==(const String& a, const StringView& b);
bool FLAXENGINE_API operator!=(const String& a, const StringView& b);
namespace fmt
{
@@ -525,8 +525,8 @@ inline uint32 GetHash(const StringAnsiView& key)
return StringUtils::GetHashCode(key.Get(), key.Length());
}
bool operator==(const StringAnsi& a, const StringAnsiView& b);
bool operator!=(const StringAnsi& a, const StringAnsiView& b);
bool FLAXENGINE_API operator==(const StringAnsi& a, const StringAnsiView& b);
bool FLAXENGINE_API operator!=(const StringAnsi& a, const StringAnsiView& b);
namespace fmt
{