diff --git a/Source/Core/Common/Assembler/CaseInsensitiveDict.h b/Source/Core/Common/Assembler/CaseInsensitiveDict.h index 8f6acccc8f..5dffbb6335 100644 --- a/Source/Core/Common/Assembler/CaseInsensitiveDict.h +++ b/Source/Core/Common/Assembler/CaseInsensitiveDict.h @@ -47,7 +47,7 @@ private: std::array _conns; std::optional _val; - TrieEntry() { std::fill(_conns.begin(), _conns.end(), INVALID_CONN); } + TrieEntry() { _conns.fill(INVALID_CONN); } }; constexpr size_t IndexOf(char c) const diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index a7d4d22639..627560e765 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -575,7 +576,7 @@ SharedContentMap::GetFilenameFromSHA1(const std::array& sha1) const if (it == m_entries.end()) return {}; - const std::string id_string(it->id.begin(), it->id.end()); + const std::string_view id_string(reinterpret_cast(it->id.data()), it->id.size()); return fmt::format("/shared1/{}.app", id_string); } @@ -591,20 +592,22 @@ std::vector> SharedContentMap::GetHashes() const std::string SharedContentMap::AddSharedContent(const std::array& sha1) { - auto filename = GetFilenameFromSHA1(sha1); - if (filename) - return *filename; + if (auto filename = GetFilenameFromSHA1(sha1)) + return *std::move(filename); - const std::string id = fmt::format("{:08x}", m_last_id); - Entry entry; - std::copy(id.cbegin(), id.cend(), entry.id.begin()); + Entry& entry = m_entries.emplace_back(); + static_assert(sizeof(m_last_id) == 4, + "'m_last_id' must be represented by 8 characters when formatted in hexadecimal."); + static_assert(std::tuple_size_v == sizeof(m_last_id) * 2, + "'entry.id' must be a std::array capable of storing every nibble of 'm_last_id'."); + fmt::format_to(entry.id.data(), "{:08x}", m_last_id); entry.sha1 = sha1; - m_entries.push_back(entry); WriteEntries(); - filename = fmt::format("/shared1/{}.app", id); m_last_id++; - return *filename; + + const std::string_view id_string(reinterpret_cast(entry.id.data()), entry.id.size()); + return fmt::format("/shared1/{}.app", id_string); } bool SharedContentMap::DeleteSharedContent(const std::array& sha1) diff --git a/Source/Core/DolphinQt/Config/ARCodeWidget.cpp b/Source/Core/DolphinQt/Config/ARCodeWidget.cpp index 933c6575ef..e7d44b8fe6 100644 --- a/Source/Core/DolphinQt/Config/ARCodeWidget.cpp +++ b/Source/Core/DolphinQt/Config/ARCodeWidget.cpp @@ -140,20 +140,14 @@ void ARCodeWidget::SortAlphabetically() void ARCodeWidget::SortEnabledCodesFirst() { - std::stable_sort(m_ar_codes.begin(), m_ar_codes.end(), [](const auto& a, const auto& b) { - return a.enabled && a.enabled != b.enabled; - }); - + std::ranges::stable_partition(m_ar_codes, std::identity{}, &ActionReplay::ARCode::enabled); UpdateList(); SaveCodes(); } void ARCodeWidget::SortDisabledCodesFirst() { - std::stable_sort(m_ar_codes.begin(), m_ar_codes.end(), [](const auto& a, const auto& b) { - return !a.enabled && a.enabled != b.enabled; - }); - + std::ranges::stable_partition(m_ar_codes, std::logical_not{}, &ActionReplay::ARCode::enabled); UpdateList(); SaveCodes(); } diff --git a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp index 76a6d11cdd..3d2bd020e4 100644 --- a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp +++ b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp @@ -314,20 +314,14 @@ void GeckoCodeWidget::SortAlphabetically() void GeckoCodeWidget::SortEnabledCodesFirst() { - std::stable_sort(m_gecko_codes.begin(), m_gecko_codes.end(), [](const auto& a, const auto& b) { - return a.enabled && a.enabled != b.enabled; - }); - + std::ranges::stable_partition(m_gecko_codes, std::identity{}, &Gecko::GeckoCode::enabled); UpdateList(); SaveCodes(); } void GeckoCodeWidget::SortDisabledCodesFirst() { - std::stable_sort(m_gecko_codes.begin(), m_gecko_codes.end(), [](const auto& a, const auto& b) { - return !a.enabled && a.enabled != b.enabled; - }); - + std::ranges::stable_partition(m_gecko_codes, std::logical_not{}, &Gecko::GeckoCode::enabled); UpdateList(); SaveCodes(); } diff --git a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp index 4edc07fd02..2c82788b99 100644 --- a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp +++ b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -284,11 +285,10 @@ void ReshapableInput::SaveConfig(Common::IniFile::Section* section, 50.0); } - std::vector save_data(m_calibration.size()); - std::transform( - m_calibration.begin(), m_calibration.end(), save_data.begin(), - [](ControlState val) { return fmt::format("{:.2f}", val * CALIBRATION_CONFIG_SCALE); }); - section->Set(group + CALIBRATION_CONFIG_NAME, fmt::to_string(fmt::join(save_data, " ")), ""); + const std::ranges::transform_view scaled_calibration( + m_calibration, [](ControlState val) { return val * CALIBRATION_CONFIG_SCALE; }); + section->Set(group + CALIBRATION_CONFIG_NAME, + fmt::format("{:.2f}", fmt::join(scaled_calibration, " ")), ""); // Save center value. static constexpr char center_format[] = "{:.2f} {:.2f}"; diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp index 01cfcd2f92..84b5022c99 100644 --- a/Source/Core/InputCommon/GCAdapter.cpp +++ b/Source/Core/InputCommon/GCAdapter.cpp @@ -915,7 +915,7 @@ static void ResetRumbleLockNeeded() return; } - std::fill(std::begin(s_controller_rumble), std::end(s_controller_rumble), 0); + s_controller_rumble.fill(0); std::array rumble = { 0x11, s_controller_rumble[0], s_controller_rumble[1], s_controller_rumble[2], diff --git a/Source/Core/UICommon/GameFile.cpp b/Source/Core/UICommon/GameFile.cpp index 5c32c511df..442added6e 100644 --- a/Source/Core/UICommon/GameFile.cpp +++ b/Source/Core/UICommon/GameFile.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -18,6 +17,7 @@ #include #include +#include #include #include "Common/BitUtils.h" @@ -642,10 +642,7 @@ std::string GameFile::GetNetPlayName(const Core::TitleDatabase& title_database) } if (info.empty()) return name; - std::ostringstream ss; - std::copy(info.begin(), info.end() - 1, std::ostream_iterator(ss, ", ")); - ss << info.back(); - return name + " (" + ss.str() + ")"; + return fmt::format("{} ({})", name, fmt::join(info, ", ")); } static Common::SHA1::Digest GetHash(u32 value)