Add strlen comparing back to StringView since it is not nullterminated
This commit is contained in:
parent
711ba19a82
commit
c21766760b
|
@ -141,7 +141,9 @@ namespace BAN
|
||||||
|
|
||||||
bool String::operator==(const char* other) const
|
bool String::operator==(const char* other) const
|
||||||
{
|
{
|
||||||
return memcmp(m_data, other, m_size + 1) == 0;
|
if (m_size != strlen(other))
|
||||||
|
return false;
|
||||||
|
return memcmp(m_data, other, m_size) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> String::Resize(size_type size, char ch)
|
ErrorOr<void> String::Resize(size_type size, char ch)
|
||||||
|
|
|
@ -45,7 +45,9 @@ namespace BAN
|
||||||
|
|
||||||
bool StringView::operator==(const char* other) const
|
bool StringView::operator==(const char* other) const
|
||||||
{
|
{
|
||||||
return memcmp(m_data, other, m_size + 1) == 0;
|
if (m_size != strlen(other))
|
||||||
|
return false;
|
||||||
|
return memcmp(m_data, other, m_size) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView StringView::Substring(size_type index, size_type len) const
|
StringView StringView::Substring(size_type index, size_type len) const
|
||||||
|
|
Loading…
Reference in New Issue