Add strlen comparing back to StringView since it is not nullterminated

This commit is contained in:
Bananymous 2022-12-13 22:45:51 +02:00
parent 711ba19a82
commit c21766760b
2 changed files with 6 additions and 2 deletions

View File

@ -141,7 +141,9 @@ namespace BAN
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)

View File

@ -45,7 +45,9 @@ namespace BAN
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