mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-29 01:35:06 +01:00
Refactor to use string_view more properly
This commit is contained in:
@@ -65,7 +65,7 @@ namespace String
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
std::string ToUtf8(const std::wstring_view& src)
|
||||
std::string ToUtf8(std::wstring_view src)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int srcLen = static_cast<int>(src.size());
|
||||
@@ -93,7 +93,7 @@ namespace String
|
||||
#endif
|
||||
}
|
||||
|
||||
std::wstring ToWideChar(const std::string_view& src)
|
||||
std::wstring ToWideChar(std::string_view src)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int srcLen = static_cast<int>(src.size());
|
||||
@@ -171,7 +171,7 @@ namespace String
|
||||
}
|
||||
}
|
||||
|
||||
bool Equals(const std::string_view a, const std::string_view b, bool ignoreCase)
|
||||
bool Equals(std::string_view a, std::string_view b, bool ignoreCase)
|
||||
{
|
||||
if (ignoreCase)
|
||||
{
|
||||
@@ -250,12 +250,12 @@ namespace String
|
||||
return StartsWith(str.c_str(), match.c_str(), ignoreCase);
|
||||
}
|
||||
|
||||
bool EndsWith(const std::string_view& str, const std::string_view& match, bool ignoreCase)
|
||||
bool EndsWith(std::string_view str, std::string_view match, bool ignoreCase)
|
||||
{
|
||||
if (str.size() >= match.size())
|
||||
{
|
||||
auto view = str.substr(str.size() - match.size());
|
||||
return Equals(view.data(), match.data(), ignoreCase);
|
||||
return Equals(view, match, ignoreCase);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -460,7 +460,7 @@ namespace String
|
||||
return DiscardUse(ptr, String::Duplicate(replacement));
|
||||
}
|
||||
|
||||
std::vector<std::string> Split(const std::string& s, const std::string& delimiter)
|
||||
std::vector<std::string> Split(std::string_view s, std::string_view delimiter)
|
||||
{
|
||||
if (delimiter.empty())
|
||||
{
|
||||
@@ -475,16 +475,14 @@ namespace String
|
||||
do
|
||||
{
|
||||
nextIndex = s.find(delimiter, index);
|
||||
std::string value;
|
||||
if (nextIndex == std::string::npos)
|
||||
{
|
||||
value = s.substr(index);
|
||||
results.emplace_back(s.substr(index));
|
||||
}
|
||||
else
|
||||
{
|
||||
value = s.substr(index, nextIndex - index);
|
||||
results.emplace_back(s.substr(index, nextIndex - index));
|
||||
}
|
||||
results.push_back(value);
|
||||
index = nextIndex + delimiter.size();
|
||||
} while (nextIndex != SIZE_MAX);
|
||||
}
|
||||
@@ -711,7 +709,7 @@ namespace String
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string Convert(const std::string_view& src, int32_t srcCodePage, int32_t dstCodePage)
|
||||
std::string Convert(std::string_view src, int32_t srcCodePage, int32_t dstCodePage)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Convert from source code page to UTF-16
|
||||
@@ -751,7 +749,7 @@ namespace String
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string ToUpper(const std::string_view& src)
|
||||
std::string ToUpper(std::string_view src)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
# if _WIN32_WINNT >= 0x0600
|
||||
|
||||
Reference in New Issue
Block a user