aboutsummaryrefslogtreecommitdiff
path: root/src/chainparams.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-02-18 07:53:27 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-02-18 07:53:37 +0100
commitcd66d8b1d8b5fcb96b80cdf167d0d1152b99aee0 (patch)
treeb4ffbfa4de549b9a61bf4764056b3422259b4442 /src/chainparams.cpp
parent372dd8da2475d7df584d31fa03f0b4d703b7c8f5 (diff)
parente829c9afbf75e930db6c3fe77a269b0af5e7a3ad (diff)
downloadbitcoin-cd66d8b1d8b5fcb96b80cdf167d0d1152b99aee0.tar.xz
Merge #20429: refactor: replace (sizeof(a)/sizeof(a[0])) with C++17 std::size
e829c9afbf75e930db6c3fe77a269b0af5e7a3ad refactor: replace sizeof(a)/sizeof(a[0]) by std::size (C++17) (Sebastian Falbesoner) 365539c84691d470b44d35df374d8c049f8c1192 refactor: init vectors via std::{begin,end} to avoid pointer arithmetic (Sebastian Falbesoner) 63d4ee1968144cc3d115f92baef95785abf813ac refactor: iterate arrays via C++11 range-based for loops if idx is not needed (Sebastian Falbesoner) Pull request description: This refactoring PR picks up the idea of #19626 and replaces all occurences of `sizeof(x)/sizeof(x[0])` (or `sizeof(x)/sizeof(*x)`, respectively) with the now-available C++17 [`std::size`](https://en.cppreference.com/w/cpp/iterator/size) (as [suggested by sipa](https://github.com/bitcoin/bitcoin/pull/19626#issuecomment-666487228)), making the macro `ARRAYLEN` obsolete. As preparation for this, two other changes are done to eliminate `sizeof(x)/sizeof(x[0])` usage: * all places where arrays are iterated via an index are changed to use C++11 range-based for loops If the index' only purpose is to access the array element (as [suggested by MarcoFalke](https://github.com/bitcoin/bitcoin/pull/19626#discussion_r463404541)). * `std::vector` initializations are done via `std::begin` and `std::end` rather than using pointer arithmetic to calculate the end (also [suggested by MarcoFalke](https://github.com/bitcoin/bitcoin/pull/20429#discussion_r567418821)). ACKs for top commit: practicalswift: cr ACK e829c9afbf75e930db6c3fe77a269b0af5e7a3ad: patch looks correct fanquake: ACK e829c9afbf75e930db6c3fe77a269b0af5e7a3ad MarcoFalke: review ACK e829c9afbf75e930db6c3fe77a269b0af5e7a3ad 🌩 Tree-SHA512: b01d32c04b9e04d562b7717cae00a651ec9a718645047a90761be6959e0cc2adbd67494e058fe894641076711bb09c3b47a047d0275c736f0b2218e1ce0d193d
Diffstat (limited to 'src/chainparams.cpp')
-rw-r--r--src/chainparams.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 97280c0d16..4796045730 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -9,7 +9,6 @@
#include <consensus/merkle.h>
#include <hash.h> // for signet block challenge hash
#include <util/system.h>
-#include <util/strencodings.h>
#include <versionbitsinfo.h>
#include <assert.h>
@@ -135,7 +134,7 @@ public:
bech32_hrp = "bc";
- vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
+ vFixedSeeds = std::vector<SeedSpec6>(std::begin(pnSeed6_main), std::end(pnSeed6_main));
fDefaultConsistencyChecks = false;
fRequireStandard = true;
@@ -240,7 +239,7 @@ public:
bech32_hrp = "tb";
- vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
+ vFixedSeeds = std::vector<SeedSpec6>(std::begin(pnSeed6_test), std::end(pnSeed6_test));
fDefaultConsistencyChecks = false;
fRequireStandard = false;