mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-03 11:32:43 +01:00
Modernize std::replace
with ranges
This commit is contained in:
parent
72436a0d1f
commit
0a80243a92
@ -107,7 +107,7 @@ std::vector<std::string> DoFileSearch(const std::vector<std::string>& directorie
|
|||||||
if constexpr (os_separator != DIR_SEP_CHR)
|
if constexpr (os_separator != DIR_SEP_CHR)
|
||||||
{
|
{
|
||||||
for (auto& path : result)
|
for (auto& path : result)
|
||||||
std::replace(path.begin(), path.end(), '\\', DIR_SEP_CHR);
|
std::ranges::replace(path, '\\', DIR_SEP_CHR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -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
|
// about with directory separators (for host paths - emulated paths may require it) and instead
|
||||||
// use fs::path to interact with them.
|
// use fs::path to interact with them.
|
||||||
auto wpath = path.wstring();
|
auto wpath = path.wstring();
|
||||||
std::replace(wpath.begin(), wpath.end(), L'\\', L'/');
|
std::ranges::replace(wpath, L'\\', L'/');
|
||||||
return WStringToUTF8(wpath);
|
return WStringToUTF8(wpath);
|
||||||
#else
|
#else
|
||||||
return PathToString(path);
|
return PathToString(path);
|
||||||
|
@ -234,8 +234,8 @@ std::string_view StripQuotes(std::string_view s)
|
|||||||
// Turns "\n\rhello" into " hello".
|
// Turns "\n\rhello" into " hello".
|
||||||
void ReplaceBreaksWithSpaces(std::string& str)
|
void ReplaceBreaksWithSpaces(std::string& str)
|
||||||
{
|
{
|
||||||
std::replace(str.begin(), str.end(), '\r', ' ');
|
std::ranges::replace(str, '\r', ' ');
|
||||||
std::replace(str.begin(), str.end(), '\n', ' ');
|
std::ranges::replace(str, '\n', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
void TruncateToCString(std::string* s)
|
void TruncateToCString(std::string* s)
|
||||||
|
@ -265,7 +265,7 @@ struct SetGameMetadata
|
|||||||
std::string executable_path = executable.path;
|
std::string executable_path = executable.path;
|
||||||
constexpr char BACKSLASH = '\\';
|
constexpr char BACKSLASH = '\\';
|
||||||
constexpr char FORWARDSLASH = '/';
|
constexpr char FORWARDSLASH = '/';
|
||||||
std::replace(executable_path.begin(), executable_path.end(), BACKSLASH, FORWARDSLASH);
|
std::ranges::replace(executable_path, BACKSLASH, FORWARDSLASH);
|
||||||
config->SetRunningGameMetadata(SConfig::MakeGameID(PathToFileName(executable_path)));
|
config->SetRunningGameMetadata(SConfig::MakeGameID(PathToFileName(executable_path)));
|
||||||
|
|
||||||
Host_TitleChanged();
|
Host_TitleChanged();
|
||||||
|
@ -225,7 +225,7 @@ void SetLocale(std::string locale_name)
|
|||||||
if (locale_name == "en")
|
if (locale_name == "en")
|
||||||
locale_name = "en_GB";
|
locale_name = "en_GB";
|
||||||
|
|
||||||
std::replace(locale_name.begin(), locale_name.end(), OTHER_SEPARATOR, PREFERRED_SEPARATOR);
|
std::ranges::replace(locale_name, OTHER_SEPARATOR, PREFERRED_SEPARATOR);
|
||||||
|
|
||||||
// Use the specified locale if supported.
|
// Use the specified locale if supported.
|
||||||
if (set_locale(locale_name))
|
if (set_locale(locale_name))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user