mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-24 15:40:26 +00:00
fix(telemetry): use std::ranges algorithms (modernize-use-ranges)
Replace std::transform with std::ranges::transform in Redaction.cpp. Replace std::all_of with std::ranges::all_of in Redaction test. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <ranges>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
@@ -23,9 +24,8 @@ redactAccount(std::string_view addr)
|
||||
// staying non-reversible — and lowercase them for a stable token.
|
||||
auto const digest = sha512Half(Slice(addr.data(), addr.size()));
|
||||
std::string token = to_string(digest).substr(0, 16);
|
||||
std::transform(token.begin(), token.end(), token.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
std::ranges::transform(
|
||||
token, token.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <ranges>
|
||||
#include <string>
|
||||
|
||||
using namespace xrpl;
|
||||
@@ -28,7 +29,7 @@ TEST(Redaction, token_is_16_lowercase_hex_and_stable)
|
||||
{
|
||||
auto const token = redactAccount("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh");
|
||||
EXPECT_EQ(token.size(), 16u);
|
||||
EXPECT_TRUE(std::all_of(token.begin(), token.end(), [](unsigned char c) {
|
||||
EXPECT_TRUE(std::ranges::all_of(token, [](unsigned char c) {
|
||||
return std::isdigit(c) || (c >= 'a' && c <= 'f');
|
||||
}));
|
||||
// Deterministic: hashing the same input twice yields the same token.
|
||||
|
||||
Reference in New Issue
Block a user