BAN: use only memcmp when comparing string(view) with const char*

This commit is contained in:
Bananymous
2022-12-13 21:32:51 +02:00
parent 833a82c8d1
commit ced05ff5f2
3 changed files with 3 additions and 8 deletions

View File

@@ -4,8 +4,6 @@
#include <BAN/String.h>
#include <BAN/StringView.h>
#include <kernel/Serial.h>
#include <assert.h>
#include <string.h>
#include <sys/param.h>
@@ -143,9 +141,7 @@ namespace BAN
bool String::operator==(const char* other) const
{
if (m_size != strlen(other))
return false;
return memcmp(m_data, other, m_size) == 0;
return memcmp(m_data, other, m_size + 1) == 0;
}
ErrorOr<void> String::Resize(size_type size, char ch)

View File

@@ -45,9 +45,7 @@ namespace BAN
bool StringView::operator==(const char* other) const
{
if (m_size != strlen(other))
return false;
return memcmp(m_data, other, m_size) == 0;
return memcmp(m_data, other, m_size + 1) == 0;
}
StringView StringView::Substring(size_type index, size_type len) const