Skip to content

Commit

Permalink
Address readability-use-anyofallof warnings.
Browse files Browse the repository at this point in the history
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)
      |   ^
```
  • Loading branch information
cristian64 committed May 4, 2024
1 parent b80ca3c commit 2272146
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions Source/GUI/MemCopy/DlgCopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <QLabel>
#include <QVBoxLayout>
#include <qmessagebox.h>

#include <algorithm>
#include <sstream>
#include <utility>
#include "../../Common/CommonUtils.h"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 2272146

Please sign in to comment.