Merge pull request #13090 from mitaclaw/ranges-modernization-1-trivial

Ranges Algorithms Modernization - Trivial
This commit is contained in:
JosJuice
2024-10-15 17:08:55 +02:00
committed by GitHub
52 changed files with 106 additions and 118 deletions

View File

@ -252,8 +252,8 @@ Signature Sign(const u8* key, const u8* hash)
bn_mul(s.data.data(), minv, kk, ec_N, 30);
Signature signature;
std::copy(r.data.cbegin(), r.data.cend(), signature.begin());
std::copy(s.data.cbegin(), s.data.cend(), signature.begin() + 30);
std::ranges::copy(r.data, signature.begin());
std::ranges::copy(s.data, signature.begin() + 30);
return signature;
}

View File

@ -97,7 +97,7 @@ std::vector<std::string> DoFileSearch(const std::vector<std::string>& directorie
// Remove duplicates (occurring because caller gave e.g. duplicate or overlapping directories -
// not because std::filesystem returns duplicates). Also note that this pathname-based uniqueness
// isn't as thorough as std::filesystem::equivalent.
std::sort(result.begin(), result.end());
std::ranges::sort(result);
result.erase(std::unique(result.begin(), result.end()), result.end());
// Dolphin expects to be able to use "/" (DIR_SEP) everywhere.
@ -107,7 +107,7 @@ std::vector<std::string> DoFileSearch(const std::vector<std::string>& directorie
if constexpr (os_separator != DIR_SEP_CHR)
{
for (auto& path : result)
std::replace(path.begin(), path.end(), '\\', DIR_SEP_CHR);
std::ranges::replace(path, '\\', DIR_SEP_CHR);
}
return result;

View File

@ -446,7 +446,7 @@ FSTEntry ScanDirectoryTree(std::string directory, bool recursive)
// about with directory separators (for host paths - emulated paths may require it) and instead
// use fs::path to interact with them.
auto wpath = path.wstring();
std::replace(wpath.begin(), wpath.end(), L'\\', L'/');
std::ranges::replace(wpath, L'\\', L'/');
return WStringToUTF8(wpath);
#else
return PathToString(path);

View File

@ -36,10 +36,10 @@ MACAddress GenerateMacAddress(const MACConsumer type)
switch (type)
{
case MACConsumer::BBA:
std::copy(oui_bba.begin(), oui_bba.end(), mac.begin());
std::ranges::copy(oui_bba, mac.begin());
break;
case MACConsumer::IOS:
std::copy(oui_ios.begin(), oui_ios.end(), mac.begin());
std::ranges::copy(oui_ios, mac.begin());
break;
}

View File

@ -234,8 +234,8 @@ std::string_view StripQuotes(std::string_view s)
// Turns "\n\rhello" into " hello".
void ReplaceBreaksWithSpaces(std::string& str)
{
std::replace(str.begin(), str.end(), '\r', ' ');
std::replace(str.begin(), str.end(), '\n', ' ');
std::ranges::replace(str, '\r', ' ');
std::ranges::replace(str, '\n', ' ');
}
void TruncateToCString(std::string* s)
@ -403,8 +403,7 @@ void StringPopBackIf(std::string* s, char c)
size_t StringUTF8CodePointCount(std::string_view str)
{
return str.size() -
std::count_if(str.begin(), str.end(), [](char c) -> bool { return (c & 0xC0) == 0x80; });
return str.size() - std::ranges::count_if(str, [](char c) -> bool { return (c & 0xC0) == 0x80; });
}
#ifdef _WIN32
@ -656,12 +655,12 @@ std::string GetEscapedHtml(std::string html)
void ToLower(std::string* str)
{
std::transform(str->begin(), str->end(), str->begin(), [](char c) { return Common::ToLower(c); });
std::ranges::transform(*str, str->begin(), static_cast<char (&)(char)>(Common::ToLower));
}
void ToUpper(std::string* str)
{
std::transform(str->begin(), str->end(), str->begin(), [](char c) { return Common::ToUpper(c); });
std::ranges::transform(*str, str->begin(), static_cast<char (&)(char)>(Common::ToUpper));
}
bool CaseInsensitiveEquals(std::string_view a, std::string_view b)