mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-29 09:05:41 +00:00
SmallString: Pass string_view by value
This commit is contained in:
parent
57aa138808
commit
2cd747983a
|
@ -39,7 +39,7 @@ SmallStringBase::SmallStringBase(SmallStringBase&& move)
|
|||
assign(std::move(move));
|
||||
}
|
||||
|
||||
SmallStringBase::SmallStringBase(const std::string_view& sv)
|
||||
SmallStringBase::SmallStringBase(const std::string_view sv)
|
||||
{
|
||||
assign(sv);
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ SmallStringBase& SmallStringBase::operator=(SmallStringBase&& move)
|
|||
return *this;
|
||||
}
|
||||
|
||||
SmallStringBase& SmallStringBase::operator=(const std::string_view& str)
|
||||
SmallStringBase& SmallStringBase::operator=(const std::string_view str)
|
||||
{
|
||||
assign(str);
|
||||
return *this;
|
||||
|
@ -219,7 +219,7 @@ void SmallStringBase::append(const std::string& str)
|
|||
append(str.c_str(), static_cast<u32>(str.length()));
|
||||
}
|
||||
|
||||
void SmallStringBase::append(const std::string_view& str)
|
||||
void SmallStringBase::append(const std::string_view str)
|
||||
{
|
||||
append(str.data(), static_cast<u32>(str.length()));
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ void SmallStringBase::prepend(const std::string& str)
|
|||
prepend(str.c_str(), static_cast<u32>(str.length()));
|
||||
}
|
||||
|
||||
void SmallStringBase::prepend(const std::string_view& str)
|
||||
void SmallStringBase::prepend(const std::string_view str)
|
||||
{
|
||||
prepend(str.data(), static_cast<u32>(str.length()));
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ void SmallStringBase::insert(s32 offset, const std::string& str)
|
|||
insert(offset, str.c_str(), static_cast<u32>(str.size()));
|
||||
}
|
||||
|
||||
void SmallStringBase::insert(s32 offset, const std::string_view& str)
|
||||
void SmallStringBase::insert(s32 offset, const std::string_view str)
|
||||
{
|
||||
insert(offset, str.data(), static_cast<u32>(str.size()));
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ void SmallStringBase::assign(const std::string& str)
|
|||
append(str.data(), static_cast<u32>(str.size()));
|
||||
}
|
||||
|
||||
void SmallStringBase::assign(const std::string_view& str)
|
||||
void SmallStringBase::assign(const std::string_view str)
|
||||
{
|
||||
clear();
|
||||
append(str.data(), static_cast<u32>(str.size()));
|
||||
|
@ -452,7 +452,7 @@ bool SmallStringBase::equals(const SmallStringBase& str) const
|
|||
return (m_length == str.m_length && (m_length == 0 || std::strcmp(m_buffer, str.m_buffer) == 0));
|
||||
}
|
||||
|
||||
bool SmallStringBase::equals(const std::string_view& str) const
|
||||
bool SmallStringBase::equals(const std::string_view str) const
|
||||
{
|
||||
return (m_length == static_cast<u32>(str.length()) &&
|
||||
(m_length == 0 || CASE_N_COMPARE(m_buffer, str.data(), m_length) == 0));
|
||||
|
@ -471,7 +471,7 @@ bool SmallStringBase::iequals(const SmallStringBase& str) const
|
|||
return (m_length == str.m_length && (m_length == 0 || std::strcmp(m_buffer, str.m_buffer) == 0));
|
||||
}
|
||||
|
||||
bool SmallStringBase::iequals(const std::string_view& str) const
|
||||
bool SmallStringBase::iequals(const std::string_view str) const
|
||||
{
|
||||
return (m_length == static_cast<u32>(str.length()) &&
|
||||
(m_length == 0 || CASE_N_COMPARE(m_buffer, str.data(), m_length) == 0));
|
||||
|
@ -517,7 +517,7 @@ bool SmallStringBase::starts_with(const SmallStringBase& str, bool case_sensitiv
|
|||
(CASE_N_COMPARE(str.m_buffer, m_buffer, other_length) == 0);
|
||||
}
|
||||
|
||||
bool SmallStringBase::starts_with(const std::string_view& str, bool case_sensitive) const
|
||||
bool SmallStringBase::starts_with(const std::string_view str, bool case_sensitive) const
|
||||
{
|
||||
const u32 other_length = static_cast<u32>(str.length());
|
||||
if (other_length > m_length)
|
||||
|
@ -549,7 +549,7 @@ bool SmallStringBase::ends_with(const SmallStringBase& str, bool case_sensitive)
|
|||
(CASE_N_COMPARE(str.m_buffer, m_buffer + start_offset, other_length) == 0);
|
||||
}
|
||||
|
||||
bool SmallStringBase::ends_with(const std::string_view& str, bool case_sensitive) const
|
||||
bool SmallStringBase::ends_with(const std::string_view str, bool case_sensitive) const
|
||||
{
|
||||
const u32 other_length = static_cast<u32>(str.length());
|
||||
if (other_length > m_length)
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
SmallStringBase(const SmallStringBase& copy);
|
||||
SmallStringBase(SmallStringBase&& move);
|
||||
SmallStringBase(const std::string& str);
|
||||
SmallStringBase(const std::string_view& sv);
|
||||
SmallStringBase(const std::string_view sv);
|
||||
|
||||
// Destructor. Child classes may not have any destructors, as this is not virtual.
|
||||
~SmallStringBase();
|
||||
|
@ -37,7 +37,7 @@ public:
|
|||
void assign(const char* str);
|
||||
void assign(const char* str, u32 length);
|
||||
void assign(const std::string& copy);
|
||||
void assign(const std::string_view& copy);
|
||||
void assign(const std::string_view copy);
|
||||
void assign(const SmallStringBase& copy);
|
||||
void assign(SmallStringBase&& move);
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
|||
void append(const char* appendText);
|
||||
void append(const char* str, u32 length);
|
||||
void append(const std::string& str);
|
||||
void append(const std::string_view& str);
|
||||
void append(const std::string_view str);
|
||||
void append(const SmallStringBase& str);
|
||||
|
||||
// append formatted string to this string
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
void prepend(const char* str);
|
||||
void prepend(const char* str, u32 length);
|
||||
void prepend(const std::string& str);
|
||||
void prepend(const std::string_view& str);
|
||||
void prepend(const std::string_view str);
|
||||
void prepend(const SmallStringBase& str);
|
||||
|
||||
// append formatted string to this string
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
void insert(s32 offset, const char* str);
|
||||
void insert(s32 offset, const char* str, u32 length);
|
||||
void insert(s32 offset, const std::string& str);
|
||||
void insert(s32 offset, const std::string_view& str);
|
||||
void insert(s32 offset, const std::string_view str);
|
||||
void insert(s32 offset, const SmallStringBase& str);
|
||||
|
||||
// set to formatted string
|
||||
|
@ -101,25 +101,25 @@ public:
|
|||
// compare one string to another
|
||||
bool equals(const char* str) const;
|
||||
bool equals(const SmallStringBase& str) const;
|
||||
bool equals(const std::string_view& str) const;
|
||||
bool equals(const std::string_view str) const;
|
||||
bool iequals(const char* str) const;
|
||||
bool iequals(const SmallStringBase& str) const;
|
||||
bool iequals(const std::string_view& str) const;
|
||||
bool iequals(const std::string_view str) const;
|
||||
|
||||
// numerical compares
|
||||
int compare(const char* str) const;
|
||||
int compare(const SmallStringBase& str) const;
|
||||
int compare(const std::string_view& str) const;
|
||||
int compare(const std::string_view str) const;
|
||||
int icompare(const char* str) const;
|
||||
int icompare(const SmallStringBase& str) const;
|
||||
int icompare(const std::string_view& str) const;
|
||||
int icompare(const std::string_view str) const;
|
||||
|
||||
// starts with / ends with
|
||||
bool starts_with(const char* str, bool case_sensitive = true) const;
|
||||
bool starts_with(const std::string_view& str, bool case_sensitive = true) const;
|
||||
bool starts_with(const std::string_view str, bool case_sensitive = true) const;
|
||||
bool starts_with(const SmallStringBase& str, bool case_sensitive = true) const;
|
||||
bool ends_with(const char* str, bool case_sensitive = true) const;
|
||||
bool ends_with(const std::string_view& str, bool case_sensitive = true) const;
|
||||
bool ends_with(const std::string_view str, bool case_sensitive = true) const;
|
||||
bool ends_with(const SmallStringBase& str, bool case_sensitive = true) const;
|
||||
|
||||
// searches for a character inside a string
|
||||
|
@ -181,21 +181,21 @@ public:
|
|||
// comparative operators
|
||||
ALWAYS_INLINE bool operator==(const char* str) const { return equals(str); }
|
||||
ALWAYS_INLINE bool operator==(const SmallStringBase& str) const { return equals(str); }
|
||||
ALWAYS_INLINE bool operator==(const std::string_view& str) const { return equals(str); }
|
||||
ALWAYS_INLINE bool operator==(const std::string_view str) const { return equals(str); }
|
||||
ALWAYS_INLINE bool operator!=(const char* str) const { return !equals(str); }
|
||||
ALWAYS_INLINE bool operator!=(const SmallStringBase& str) const { return !equals(str); }
|
||||
ALWAYS_INLINE bool operator!=(const std::string_view& str) const { return !equals(str); }
|
||||
ALWAYS_INLINE bool operator!=(const std::string_view str) const { return !equals(str); }
|
||||
ALWAYS_INLINE bool operator<(const char* str) const { return (compare(str) < 0); }
|
||||
ALWAYS_INLINE bool operator<(const SmallStringBase& str) const { return (compare(str) < 0); }
|
||||
ALWAYS_INLINE bool operator<(const std::string_view& str) const { return (compare(str) < 0); }
|
||||
ALWAYS_INLINE bool operator<(const std::string_view str) const { return (compare(str) < 0); }
|
||||
ALWAYS_INLINE bool operator>(const char* str) const { return (compare(str) > 0); }
|
||||
ALWAYS_INLINE bool operator>(const SmallStringBase& str) const { return (compare(str) > 0); }
|
||||
ALWAYS_INLINE bool operator>(const std::string_view& str) const { return (compare(str) > 0); }
|
||||
ALWAYS_INLINE bool operator>(const std::string_view str) const { return (compare(str) > 0); }
|
||||
|
||||
SmallStringBase& operator=(const SmallStringBase& copy);
|
||||
SmallStringBase& operator=(const char* str);
|
||||
SmallStringBase& operator=(const std::string& str);
|
||||
SmallStringBase& operator=(const std::string_view& str);
|
||||
SmallStringBase& operator=(const std::string_view str);
|
||||
SmallStringBase& operator=(SmallStringBase&& move);
|
||||
|
||||
protected:
|
||||
|
@ -255,7 +255,7 @@ public:
|
|||
assign(move);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE SmallStackString(const std::string_view& sv)
|
||||
ALWAYS_INLINE SmallStackString(const std::string_view sv)
|
||||
{
|
||||
init();
|
||||
assign(sv);
|
||||
|
@ -285,7 +285,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE SmallStackString& operator=(const std::string_view& sv)
|
||||
ALWAYS_INLINE SmallStackString& operator=(const std::string_view sv)
|
||||
{
|
||||
assign(sv);
|
||||
return *this;
|
||||
|
|
Loading…
Reference in a new issue