From 249defa72b1da2a806a18cd93c7300c3aa1a844f Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Sat, 21 Sep 2024 23:46:43 -0700 Subject: [PATCH] Modernize `std::equal` with ranges --- Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp | 3 +-- Source/Core/InputCommon/ControllerEmu/ControllerEmu.h | 3 +-- Source/UnitTests/Common/SettingsHandlerTest.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp index e33ba4c214..4651a27a80 100644 --- a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp +++ b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp @@ -191,8 +191,7 @@ void FIFOAnalyzer::UpdateTree() // We shouldn't end on a Command (it should end with an EFB copy) ASSERT(part_start == frame_info.parts.size()); // The counts we computed should match the frame's counts - ASSERT(std::equal(frame_info.part_type_counts.begin(), frame_info.part_type_counts.end(), - part_counts.begin())); + ASSERT(std::ranges::equal(frame_info.part_type_counts, part_counts)); } } diff --git a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h index b77b2ce3ed..88c14cfdb1 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h @@ -53,8 +53,7 @@ struct TwoPointCalibration } else { - return std::equal(std::begin(max.data), std::end(max.data), std::begin(zero.data), - std::not_equal_to<>()); + return std::ranges::equal(max.data, zero.data, std::ranges::not_equal_to{}); } } diff --git a/Source/UnitTests/Common/SettingsHandlerTest.cpp b/Source/UnitTests/Common/SettingsHandlerTest.cpp index f480c0636e..360a2221a5 100644 --- a/Source/UnitTests/Common/SettingsHandlerTest.cpp +++ b/Source/UnitTests/Common/SettingsHandlerTest.cpp @@ -47,7 +47,7 @@ TEST(SettingsHandlerTest, EncryptSingleSetting) handler.AddSetting("key", "val"); Common::SettingsHandler::Buffer buffer = handler.GetBytes(); - EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), BUFFER_A.begin(), BUFFER_A.end())); + EXPECT_TRUE(std::ranges::equal(buffer, BUFFER_A)); } TEST(SettingsHandlerTest, DecryptSingleSetting) @@ -64,7 +64,7 @@ TEST(SettingsHandlerTest, EncryptMultipleSettings) handler.AddSetting("foo", "bar"); Common::SettingsHandler::Buffer buffer = handler.GetBytes(); - EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), BUFFER_B.begin(), BUFFER_B.end())); + EXPECT_TRUE(std::ranges::equal(buffer, BUFFER_B)); } TEST(SettingsHandlerTest, DecryptMultipleSettings) @@ -88,7 +88,7 @@ TEST(SettingsHandlerTest, EncryptAddsLFOnNullChar) handler.AddSetting("\xFA", "a"); Common::SettingsHandler::Buffer buffer = handler.GetBytes(); - EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), BUFFER_C.begin(), BUFFER_C.end())); + EXPECT_TRUE(std::ranges::equal(buffer, BUFFER_C)); } TEST(SettingsHandlerTest, EncryptAddsLFOnNullCharTwice) @@ -97,7 +97,7 @@ TEST(SettingsHandlerTest, EncryptAddsLFOnNullCharTwice) handler.AddSetting("\xFA\xE9", "a"); Common::SettingsHandler::Buffer buffer = handler.GetBytes(); - EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), BUFFER_D.begin(), BUFFER_D.end())); + EXPECT_TRUE(std::ranges::equal(buffer, BUFFER_D)); } TEST(SettingsHandlerTest, DecryptSingleAddedLF)