BAN: use only memcmp when comparing string(view) with const char*
This commit is contained in:
parent
833a82c8d1
commit
ced05ff5f2
|
@ -4,8 +4,6 @@
|
||||||
#include <BAN/String.h>
|
#include <BAN/String.h>
|
||||||
#include <BAN/StringView.h>
|
#include <BAN/StringView.h>
|
||||||
|
|
||||||
#include <kernel/Serial.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
@ -143,9 +141,7 @@ namespace BAN
|
||||||
|
|
||||||
bool String::operator==(const char* other) const
|
bool String::operator==(const char* other) const
|
||||||
{
|
{
|
||||||
if (m_size != strlen(other))
|
return memcmp(m_data, other, m_size + 1) == 0;
|
||||||
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,9 +45,7 @@ namespace BAN
|
||||||
|
|
||||||
bool StringView::operator==(const char* other) const
|
bool StringView::operator==(const char* other) const
|
||||||
{
|
{
|
||||||
if (m_size != strlen(other))
|
return memcmp(m_data, other, m_size + 1) == 0;
|
||||||
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
|
||||||
|
|
|
@ -38,6 +38,7 @@ kernel/PIC.o \
|
||||||
kernel/PIT.o \
|
kernel/PIT.o \
|
||||||
kernel/RTC.o \
|
kernel/RTC.o \
|
||||||
kernel/Serial.o \
|
kernel/Serial.o \
|
||||||
|
kernel/Shell.o \
|
||||||
kernel/SSP.o \
|
kernel/SSP.o \
|
||||||
icxxabi.o \
|
icxxabi.o \
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue