0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-04 10:07:27 -05:00
bitcoin-bitcoin-core/src/util
fanquake f436bfd126
Merge bitcoin/bitcoin#22953: refactor: introduce single-separator split helper (boost::split replacement)
a62e84438d fuzz: add `SplitString` fuzz target (MarcoFalke)
4fad7e46d9 test: add unit tests for `SplitString` helper (Kiminuo)
9cc8e876e4 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 fe8a7dcd78). 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 a62e84438d. 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
2022-04-26 09:54:49 +01:00
..
asmap.cpp refactor: replace boost::filesystem with std::filesystem 2022-02-03 18:35:52 +08:00
asmap.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
bip32.cpp scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
bip32.h scripted-diff: Use [[nodiscard]] (C++17) instead of NODISCARD 2020-11-26 09:05:59 +00:00
bytevectorhash.cpp refactor: use Span in random.* 2022-03-23 17:36:33 -05:00
bytevectorhash.h blockfilter: Use unordered_set instead of set in blockfilter. 2018-11-05 09:30:56 -08:00
check.cpp util/check: stop using lambda for Assert/Assume 2022-03-30 23:09:13 +10:00
check.h util/check: Add CHECK_NONFATAL identity function, NONFATAL_UNREACHABLE AND UNREACHABLE macros 2022-04-16 15:07:41 +02:00
epochguard.h util, refactor: Add UNIQUE_NAME helper macro 2022-02-16 14:59:20 +02:00
error.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
error.h rpc: send: support external signer 2021-02-23 14:34:32 +01:00
fastrange.h Add FastRange32 function and use it throughout the codebase 2022-01-07 13:37:47 -05:00
fees.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
fees.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
getuniquepath.cpp doc: add missing copyright header to getuniquepath.cpp 2021-09-08 16:28:21 +08:00
getuniquepath.h Introduce GetUniquePath(base) helper method to replace boost::filesystem::unique_path() which is not available in std::filesystem. 2021-02-04 11:38:09 +01:00
golombrice.h [moveonly] Move MapIntoRange() to separate util/fastrange.h 2022-01-06 11:27:06 -05:00
hash_type.h move-only: Add util/hash_type 2021-05-11 10:38:18 +02:00
hasher.cpp Add generic SaltedSipHasher 2020-11-10 14:33:37 -05:00
hasher.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
macros.h util, refactor: Add UNIQUE_NAME helper macro 2022-02-16 14:59:20 +02:00
message.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
message.h Move direct calls to MessageSign into new SignMessage functions in CWallet and ScriptPubKeyMan 2020-03-09 11:16:20 -04:00
moneystr.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
moneystr.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
overflow.h util: Add SaturatingAdd helper 2022-02-21 14:32:53 +01:00
overloaded.h refactor: Make CWalletTx sync state type-safe 2021-11-15 09:11:44 -05:00
rbf.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
rbf.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
readwritefile.cpp util: Fix ReadBinaryFile reading beyond maxsize 2022-02-19 18:39:43 +08:00
readwritefile.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
serfloat.cpp Add platform-independent float encoder/decoder 2021-05-24 16:04:44 -07:00
serfloat.h Add platform-independent float encoder/decoder 2021-05-24 16:04:44 -07:00
settings.cpp refactor: replace boost::filesystem with std::filesystem 2022-02-03 18:35:52 +08:00
settings.h Add <datadir>/settings.json persistent settings storage. 2020-07-11 05:41:12 -04:00
sock.cpp net: add new method Sock::SetSockOpt() that wraps setsockopt() 2022-04-15 09:14:49 +02:00
sock.h net: add new method Sock::SetSockOpt() that wraps setsockopt() 2022-04-15 09:14:49 +02:00
spanparsing.cpp refactor: introduce single-separator split helper SplitString 2022-04-11 22:19:46 +02:00
spanparsing.h refactor: introduce single-separator split helper SplitString 2022-04-11 22:19:46 +02:00
strencodings.cpp Merge bitcoin/bitcoin#24297: Fix unintended unsigned integer overflow in strencodings 2022-02-10 07:17:32 +00:00
strencodings.h util: Restore GetIntArg saturating behavior 2022-01-11 19:54:36 -05:00
string.cpp util: Add Join helper to join a list of strings 2019-08-20 16:51:41 -04:00
string.h refactor: introduce single-separator split helper SplitString 2022-04-11 22:19:46 +02:00
syscall_sandbox.cpp Remove gui-only syscalls 2022-04-05 13:30:06 +02:00
syscall_sandbox.h init: Disable syscall sandbox in the bitcoin-qt process 2022-04-05 13:29:42 +02:00
system.cpp build: Fix Boost.Process test for Boost 1.78 2022-03-21 16:52:27 +00:00
system.h util: Add GetPathArg default path argument 2022-03-02 06:09:27 -05:00
thread.cpp refactor: Make TraceThread a non-template free function 2021-04-25 12:28:44 +03:00
thread.h refactor: Make TraceThread a non-template free function 2021-04-25 12:28:44 +03:00
threadnames.cpp refactor: add missing std:: includes to threadnames.cpp 2022-04-01 14:49:13 +01:00
threadnames.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
time.cpp Simplify GetTime 2022-04-16 13:15:14 +02:00
time.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
tokenpipe.cpp refactor: post Optional<> removal cleanups 2021-03-17 14:56:20 +08:00
tokenpipe.h util: Add RAII TokenPipe 2021-03-04 18:24:00 +01:00
trace.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
translation.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
types.h Add util/types.h with ALWAYS_FALSE template 2021-09-07 19:19:02 +02:00
ui_change_type.h wallet: Do not include server symbols 2020-06-27 11:39:09 -04:00
url.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
url.h scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
vector.h Add some general std::vector utility functions 2019-10-16 08:56:57 -07:00