Use more fmt::split_sv

This commit is contained in:
Megamouse 2026-06-16 00:38:47 +02:00
parent a4649475b6
commit fbe9ad0f45
4 changed files with 12 additions and 10 deletions

View File

@ -29,7 +29,7 @@ void fmt_class_string<cheat_type>::format(std::string& out, u64 arg)
bool cheat_info::from_str(std::string_view cheat_line) bool cheat_info::from_str(std::string_view cheat_line)
{ {
const auto cheat_vec = fmt::split(cheat_line, {"@@@"}, false); auto cheat_vec = fmt::split(cheat_line, {"@@@"}, false);
s64 val64 = 0; s64 val64 = 0;
if (cheat_vec.size() != 5 || !try_to_int64(&val64, cheat_vec[2], 0, cheat_type_max - 1)) if (cheat_vec.size() != 5 || !try_to_int64(&val64, cheat_vec[2], 0, cheat_type_max - 1))
@ -38,11 +38,11 @@ bool cheat_info::from_str(std::string_view cheat_line)
return false; return false;
} }
game = cheat_vec[0]; game = std::move(cheat_vec[0]);
description = cheat_vec[1]; description = std::move(cheat_vec[1]);
type = cheat_type{::narrow<u8>(val64)}; type = cheat_type{::narrow<u8>(val64)};
offset = std::stoul(cheat_vec[3]); offset = std::stoul(cheat_vec[3]);
red_script = cheat_vec[4]; red_script = std::move(cheat_vec[4]);
return true; return true;
} }

View File

@ -77,7 +77,7 @@ void cfg_camera::camera_setting::from_string(std::string_view text)
return; return;
} }
const std::vector<std::string> list = fmt::split(text, { "," }); const std::vector<std::string_view> list = fmt::split_sv(text, { "," });
if (list.size() != member_count) if (list.size() != member_count)
{ {

View File

@ -208,22 +208,23 @@ namespace utils
content << proc_stat.rdbuf(); content << proc_stat.rdbuf();
proc_stat.close(); proc_stat.close();
const std::vector<std::string> lines = fmt::split(content.str(), {"\n"}); const std::string content_str = content.str();
const std::vector<std::string_view> lines = fmt::split_sv(content_str, {"\n"});
if (lines.empty()) if (lines.empty())
{ {
perf_log.error("/proc/stat is empty"); perf_log.error("/proc/stat is empty");
return; return;
} }
for (const std::string& line : lines) for (const std::string_view& line : lines)
{ {
const std::vector<std::string> tokens = fmt::split(line, {" "}); const std::vector<std::string_view> tokens = fmt::split_sv(line, {" "});
if (tokens.size() < 5) if (tokens.size() < 5)
{ {
return; return;
} }
const std::string& token = tokens[0]; const std::string_view token = tokens[0];
if (!token.starts_with("cpu")) if (!token.starts_with("cpu"))
{ {
return; return;

View File

@ -765,7 +765,8 @@ utils::OS_version utils::get_OS_version()
#else #else
if (struct utsname details = {}; !uname(&details)) if (struct utsname details = {}; !uname(&details))
{ {
const std::vector<std::string> version_list = fmt::split(details.release, { "." }); const std::string_view release = details.release;
const std::vector<std::string_view> version_list = fmt::split_sv(release, { "." });
const auto get_version_part = [&version_list](usz i) -> usz const auto get_version_part = [&version_list](usz i) -> usz
{ {
if (version_list.size() <= i) return 0; if (version_list.size() <= i) return 0;