From 22721464a3961fce43822c2f079a16f532ca8f36 Mon Sep 17 00:00:00 2001 From: cristian64 Date: Sat, 4 May 2024 22:55:09 +0100 Subject: [PATCH] Address `readability-use-anyofallof` warnings. The warnings were: ``` /w/dolphin-memory-engine/Source/GUI/MemCopy/DlgCopy.cpp:169:3: warning: replace loop by 'std::ranges::all_of()' [readability-use-anyofallof] 169 | for (char c : str) | ^ /w/dolphin-memory-engine/Source/GUI/MemCopy/DlgCopy.cpp:200:3: warning: replace loop by 'std::ranges::all_of()' [readability-use-anyofallof] 200 | for (char c : str) | ^ ``` --- Source/GUI/MemCopy/DlgCopy.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/Source/GUI/MemCopy/DlgCopy.cpp b/Source/GUI/MemCopy/DlgCopy.cpp index 5b196b98..34cd215f 100644 --- a/Source/GUI/MemCopy/DlgCopy.cpp +++ b/Source/GUI/MemCopy/DlgCopy.cpp @@ -6,6 +6,8 @@ #include #include #include + +#include #include #include #include "../../Common/CommonUtils.h" @@ -166,15 +168,9 @@ bool DlgCopy::isHexString(std::string_view str) str = str.substr(2); } - for (char c : str) - { - if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) - { - continue; - } - return false; - } - return true; + return std::ranges::all_of(str.cbegin(), str.cend(), [](const char c) { + return ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F'); + }); } bool DlgCopy::hexStringToU32(const std::string_view str, u32& output) @@ -197,15 +193,8 @@ bool DlgCopy::hexStringToU32(const std::string_view str, u32& output) bool DlgCopy::isUnsignedIntegerString(const std::string_view str) { - for (char c : str) - { - if (c >= '0' && c <= '9') - { - continue; - } - return false; - } - return true; + return std::ranges::all_of(str.cbegin(), str.cend(), + [](const char c) { return '0' <= c && c <= '9'; }); } bool DlgCopy::uintStringToU32(const std::string_view str, u32& output)