Skip to content

Commit 690a719

Browse files
committed
refactor: use constexpr std::{copy, fill} in V2ShortIDs
1 parent 1269ac2 commit 690a719

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/net.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,16 +1119,9 @@ constexpr std::array<std::string_view, 256> V2ShortIDs() {
11191119
static_assert(std::size(V2_DASH_IDS) <= 128);
11201120

11211121
std::array<std::string_view, 256> ret{};
1122-
for (size_t idx{0}; idx < std::size(ret); idx++) {
1123-
if (idx < 128 && idx < std::size(V2_BITCOIN_IDS)) {
1124-
ret[idx] = V2_BITCOIN_IDS[idx];
1125-
} else if (idx >= 128 && idx - 128 < std::size(V2_DASH_IDS)) {
1126-
ret[idx] = V2_DASH_IDS[idx - 128];
1127-
} else {
1128-
ret[idx] = "";
1129-
}
1130-
}
1131-
1122+
std::fill(ret.begin(), ret.end(), "");
1123+
std::copy(V2_BITCOIN_IDS.begin(), V2_BITCOIN_IDS.end(), ret.begin());
1124+
std::copy(V2_DASH_IDS.begin(), V2_DASH_IDS.end(), ret.begin() + 128);
11321125
return ret;
11331126
}
11341127

0 commit comments

Comments
 (0)