BAN: String and StringView don't have to compute strlen for equality
This commit is contained in:
parent
c82caacbaa
commit
d5a068f90c
|
@ -141,9 +141,9 @@ namespace BAN
|
|||
|
||||
bool String::operator==(const char* other) const
|
||||
{
|
||||
if (m_size != strlen(other))
|
||||
if (memcmp(m_data, other, m_size))
|
||||
return false;
|
||||
return memcmp(m_data, other, m_size) == 0;
|
||||
return other[m_size] == '\0';
|
||||
}
|
||||
|
||||
ErrorOr<void> String::Resize(size_type size, char ch)
|
||||
|
|
|
@ -45,9 +45,9 @@ namespace BAN
|
|||
|
||||
bool StringView::operator==(const char* other) const
|
||||
{
|
||||
if (m_size != strlen(other))
|
||||
if (memcmp(m_data, other, m_size))
|
||||
return false;
|
||||
return memcmp(m_data, other, m_size) == 0;
|
||||
return other[m_size] == '\0';
|
||||
}
|
||||
|
||||
StringView StringView::Substring(size_type index, size_type len) const
|
||||
|
|
Loading…
Reference in New Issue