Common: Replace StringBeginsWith/StringEndsWith with std equivalents

Obsoletes these functions in favor of the standard member functions
added in C++20.
This commit is contained in:
Lioncash
2023-01-24 14:25:49 -05:00
parent ba6ee9d7ba
commit e5b91f00b0
21 changed files with 57 additions and 97 deletions

View File

@ -64,13 +64,13 @@ FileDataLoaderHostFS::MakeAbsoluteFromRelative(std::string_view external_relativ
return std::nullopt;
#endif
std::string result = StringBeginsWith(external_relative_path, "/") ? m_sd_root : m_patch_root;
std::string result = external_relative_path.starts_with('/') ? m_sd_root : m_patch_root;
std::string_view work = external_relative_path;
// Strip away all leading and trailing path separators.
while (StringBeginsWith(work, "/"))
while (work.starts_with('/'))
work.remove_prefix(1);
while (StringEndsWith(work, "/"))
while (work.ends_with('/'))
work.remove_suffix(1);
size_t depth = 0;
while (true)
@ -126,7 +126,7 @@ FileDataLoaderHostFS::MakeAbsoluteFromRelative(std::string_view external_relativ
work = work.substr(separator_position + 1);
// Remove any potential extra path separators.
while (StringBeginsWith(work, "/"))
while (work.starts_with('/'))
work = work.substr(1);
}
return result;
@ -425,9 +425,9 @@ static void ApplyFolderPatchToFST(const Patch& patch, const Folder& folder,
return std::string(b);
if (b.empty())
return std::string(a);
if (StringEndsWith(a, "/"))
if (a.ends_with('/'))
a.remove_suffix(1);
if (StringBeginsWith(b, "/"))
if (b.starts_with('/'))
b.remove_prefix(1);
return fmt::format("{}/{}", a, b);
};