diff options
author | fanquake <fanquake@gmail.com> | 2022-04-26 09:30:34 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-04-26 09:54:49 +0100 |
commit | f436bfd126adaa64daba2e78016eb707e37eabce (patch) | |
tree | 1bb4dfcaf306fee1f5ee66e07e3c1aa54bec6675 /src/randomenv.cpp | |
parent | a19f641a80cb2841ca9f593e9be589dbc4b4ae7c (diff) | |
parent | a62e84438d27ee6213219fe2c233e58814fcbb5d (diff) | |
download | bitcoin-f436bfd126adaa64daba2e78016eb707e37eabce.tar.xz |
Merge bitcoin/bitcoin#22953: refactor: introduce single-separator split helper (boost::split replacement)
a62e84438d27ee6213219fe2c233e58814fcbb5d fuzz: add `SplitString` fuzz target (MarcoFalke)
4fad7e46d94a0fdee4ff917e81360d7ae6bd8110 test: add unit tests for `SplitString` helper (Kiminuo)
9cc8e876e412056ed22d364538f0da3d5d71946d refactor: introduce single-separator split helper `SplitString` (Sebastian Falbesoner)
Pull request description:
This PR adds a simple string split helper `SplitString` that takes use of the spanparsing `Split` function that was first introduced in #13697 (commit fe8a7dcd78cfeedc9a7c705e91384f793822912b). This enables to replace most calls to `boost::split`, in the cases where only a single separator character is used. Note that while previous attempts to replace `boost::split` were controversial (e.g. #13751), this one has a trivial implementation: it merely uses an internal helper (that is unit tested and in regular use with output descriptiors) and converts its result from spans to strings. As a drawback though, not all `boost::split` instances can be tackled.
As a possible optimization, one could return a vector of `std::string_view`s (available since C++17) instead of strings, to avoid copies. This would need more carefulness on the caller sites though, to avoid potential lifetime issues, and it's probably not worth it, considering that none of the places where strings are split are really performance-critical.
ACKs for top commit:
martinus:
Code review ACK a62e84438d27ee6213219fe2c233e58814fcbb5d. Ran all tests. I also like that with `boost::split` it was not obvious that the resulting container was cleared, and with `SplitString` API that's obvious.
Tree-SHA512: 10cb22619ebe46831b1f8e83584a89381a036b54c88701484ac00743e2a62cfe52c9f3ecdbb2d0815e536c99034558277cc263600ec3f3588b291c07eef8ed24
Diffstat (limited to 'src/randomenv.cpp')
0 files changed, 0 insertions, 0 deletions