mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
StringUtil: Remove JoinStrings
With 12 uses of `JoinStrings` in the codebase vs 36 uses of `fmt::join`, fmtlib's range adapter for string concatenation with delimiters is clearly the preferred option.
This commit is contained in:
@ -28,6 +28,7 @@
|
||||
#endif
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
@ -332,5 +333,5 @@ std::string CPUInfo::Summarize()
|
||||
if (bSHA2)
|
||||
sum.push_back("SHA2");
|
||||
|
||||
return JoinStrings(sum, ",");
|
||||
return fmt::to_string(fmt::join(sum, ","));
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
@ -141,7 +142,7 @@ std::string EscapePath(const std::string& path)
|
||||
for (const std::string& split_string : split_strings)
|
||||
escaped_split_strings.push_back(EscapeFileName(split_string));
|
||||
|
||||
return JoinStrings(escaped_split_strings, "/");
|
||||
return fmt::to_string(fmt::join(escaped_split_strings, "/"));
|
||||
}
|
||||
|
||||
std::string UnescapeFileName(const std::string& filename)
|
||||
|
@ -368,21 +368,6 @@ std::vector<std::string> SplitString(const std::string& str, const char delim)
|
||||
return output;
|
||||
}
|
||||
|
||||
std::string JoinStrings(const std::vector<std::string>& strings, const std::string& delimiter)
|
||||
{
|
||||
// Check if we can return early, just for speed
|
||||
if (strings.empty())
|
||||
return "";
|
||||
|
||||
std::ostringstream res;
|
||||
std::copy(strings.begin(), strings.end(),
|
||||
std::ostream_iterator<std::string>(res, delimiter.c_str()));
|
||||
|
||||
// Drop the trailing delimiter.
|
||||
std::string joined = res.str();
|
||||
return joined.substr(0, joined.length() - delimiter.length());
|
||||
}
|
||||
|
||||
std::string TabsToSpaces(int tab_size, std::string str)
|
||||
{
|
||||
const std::string spaces(tab_size, ' ');
|
||||
|
@ -200,7 +200,6 @@ std::from_chars_result FromChars(std::string_view sv, T& value,
|
||||
std::string TabsToSpaces(int tab_size, std::string str);
|
||||
|
||||
std::vector<std::string> SplitString(const std::string& str, char delim);
|
||||
std::string JoinStrings(const std::vector<std::string>& strings, const std::string& delimiter);
|
||||
|
||||
// "C:/Windows/winhelp.exe" to "C:/Windows/", "winhelp", ".exe"
|
||||
// This requires forward slashes to be used for the path separators, even on Windows.
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <thread>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Intrinsics.h"
|
||||
@ -275,5 +276,5 @@ std::string CPUInfo::Summarize()
|
||||
if (bSHA2)
|
||||
sum.push_back("SHA2");
|
||||
|
||||
return JoinStrings(sum, ",");
|
||||
return fmt::to_string(fmt::join(sum, ","));
|
||||
}
|
||||
|
Reference in New Issue
Block a user