mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 04:08:55 +00:00
IniFile: Migrate Common::CaseInsensitiveLess
to StringUtil
Migrating `Common::CaseInsensitiveLess` to StringUtil.h will hopefully discourage rolling one's own solution in the future for case-insensitive associative containers when this (quite robust!) solution already exists. `Common::CaseInsensitiveStringCompare::IsEqual` was removed in favor of using the `Common::CaseInsensitiveEquals` function. The `a.size() != b.size()` condition in `Common::CaseInsensitiveEquals` can be removed, since `std::ranges::equal` already checks this condition (confirmed in libc++).
This commit is contained in:
parent
067bdaa3dd
commit
508ccc2054
4 changed files with 19 additions and 30 deletions
|
@ -681,10 +681,14 @@ void ToUpper(std::string* str)
|
|||
|
||||
bool CaseInsensitiveEquals(std::string_view a, std::string_view b)
|
||||
{
|
||||
if (a.size() != b.size())
|
||||
return false;
|
||||
return std::equal(a.begin(), a.end(), b.begin(),
|
||||
[](char ca, char cb) { return Common::ToLower(ca) == Common::ToLower(cb); });
|
||||
return std::ranges::equal(
|
||||
a, b, [](char ca, char cb) { return Common::ToLower(ca) == Common::ToLower(cb); });
|
||||
}
|
||||
|
||||
bool CaseInsensitiveLess::operator()(std::string_view a, std::string_view b) const
|
||||
{
|
||||
return std::ranges::lexicographical_compare(
|
||||
a, b, [](char ca, char cb) { return Common::ToLower(ca) < Common::ToLower(cb); });
|
||||
}
|
||||
|
||||
std::string BytesToHexString(std::span<const u8> bytes)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue