0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-08 14:34:53 -05:00
bitcoin-core/src/util
Ava Chow 6dda050865
Merge bitcoin/bitcoin#29458: refactor: Preallocate result in TryParseHex to avoid resizing
a19235c14b Preallocate result in `TryParseHex` to avoid resizing (Lőrinc)
b7489ecb52 Add benchmark for TryParseHex (Lőrinc)

Pull request description:

  This pull request introduces optimizations to the `TryParseHex` function, focusing primarily on the ideal case (valid hexadecimal input without spaces).
  A new benchmark, `HexParse` was introduced in a separate commit.

  The main optimization preallocates the result vector based on the input string's length. This aims to completely avoid costly dynamic reallocations when no spaces are present.

  ------------

  Before:
  ```
  |           ns/base16 |            base16/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |                1.60 |      623,238,893.11 |    0.3% |      0.01 | `HexParse`
  |                1.65 |      606,747,566.34 |    0.6% |      0.01 | `HexParse`
  |                1.60 |      626,149,544.07 |    0.3% |      0.01 | `HexParse`
  ```

  After:
  ```
  |           ns/base16 |            base16/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |                0.68 |    1,465,555,976.27 |    0.8% |      0.01 | `HexParse`
  |                0.68 |    1,472,962,920.18 |    0.3% |      0.01 | `HexParse`
  |                0.68 |    1,476,159,423.00 |    0.3% |      0.01 | `HexParse`
  ```

ACKs for top commit:
  achow101:
    ACK a19235c14b
  hebasto:
    ACK a19235c14b.
  andrewtoth:
    Re-ACK a19235c14b
  Empact:
    Re-ACK a19235c14b

Tree-SHA512: e09a59791104be3fd1026862ce98de9efafa1f949626fa01e3b7d58e6a2ef02a11f0de55ddba5c43230a53effd24e6d368c1e12848b17e8ce91d7908a59333f0
2024-03-11 09:59:35 -04:00
..
any.h refactor: Split util::AnyPtr into its own file 2023-05-20 12:03:33 +02:00
asmap.cpp crypto: replace CountBits with std::bit_width 2024-02-26 16:13:12 +00:00
asmap.h
batchpriority.cpp refactor: Move ScheduleBatchPriority to its own file 2023-05-20 12:03:30 +02:00
batchpriority.h refactor: Move ScheduleBatchPriority to its own file 2023-05-20 12:03:30 +02:00
bip32.cpp Merge bitcoin/bitcoin#26076: Switch hardened derivation marker to h 2023-05-08 13:31:28 -04:00
bip32.h
bitdeque.h
bytevectorhash.cpp refactor: use Span for SipHash::Write 2023-07-17 13:27:46 +02:00
bytevectorhash.h
chaintype.cpp refactor: Create chaintype files 2023-05-09 11:33:09 +02:00
chaintype.h refactor: Create chaintype files 2023-05-09 11:33:09 +02:00
check.cpp removed StrFormatInternalBug quote delimitation 2023-08-18 04:04:06 +00:00
check.h Export assert from util/check.h 2023-11-24 13:11:36 +01:00
epochguard.h
error.cpp
error.h
exception.cpp
exception.h
fastrange.h
fees.cpp
fees.h
fs.cpp Add tests for C++20 std::u8string 2023-12-11 17:42:05 +01:00
fs.h refactor: Rename fs::path::u8string() to fs::path::utf8string() 2023-12-14 16:22:40 +01:00
fs_helpers.cpp Merge bitcoin/bitcoin#28075: util: Remove DirIsWritable, GetUniquePath 2023-12-13 10:06:16 +00:00
fs_helpers.h Remove DirIsWritable, GetUniquePath 2023-10-26 10:32:56 +02:00
golombrice.h
hash_type.h
hasher.cpp refactor: use Span for SipHash::Write 2023-07-17 13:27:46 +02:00
hasher.h Bump g++ minimum supported version to 10 2023-10-30 15:12:26 +01:00
insert.h refactor: Split util::insert into its own file 2023-05-20 12:03:31 +02:00
macros.h
message.cpp Make WitnessUnknown members private 2023-09-12 12:14:31 -04:00
message.h
moneystr.cpp
moneystr.h
overflow.h
overloaded.h doc: Clarify C++20 comments 2024-01-05 11:22:31 +01:00
rbf.cpp
rbf.h
readwritefile.cpp
readwritefile.h
result.h util: Add void support to util::Result 2023-05-24 08:55:47 -04:00
serfloat.cpp
serfloat.h
signalinterrupt.cpp util: Get rid of uncaught exceptions thrown by SignalInterrupt class 2023-12-04 15:39:15 -04:00
signalinterrupt.h util: Get rid of uncaught exceptions thrown by SignalInterrupt class 2023-12-04 15:39:15 -04:00
sock.cpp sock: change Sock::SendComplete() to take Span 2023-10-31 18:19:22 +01:00
sock.h sock: change Sock::SendComplete() to take Span 2023-10-31 18:19:22 +01:00
spanparsing.cpp
spanparsing.h
strencodings.cpp Preallocate result in TryParseHex to avoid resizing 2024-02-28 17:23:54 +00:00
strencodings.h doc: remove out-of-date external link in src/util/strencodings.h 2023-08-24 15:51:25 -06:00
string.cpp
string.h test: Throw error when -signetchallenge is non-hex 2023-05-25 19:24:05 +02:00
syserror.cpp Show descriptive error messages when FileCommit fails 2023-06-30 09:48:21 -04:00
syserror.h Show descriptive error messages when FileCommit fails 2023-06-30 09:48:21 -04:00
task_runner.h kernel: Remove dependency on CScheduler 2024-02-16 17:12:52 +01:00
thread.cpp
thread.h
threadinterrupt.cpp
threadinterrupt.h util: Add SignalInterrupt class and use in shutdown.cpp 2023-06-28 09:49:28 +02:00
threadnames.cpp
threadnames.h
time.cpp refactor: Remove unused GetTimeMillis 2023-05-08 12:40:48 +02:00
time.h [refactor] Remove compat.h from kernel headers 2023-09-12 22:51:48 +02:00
tokenpipe.cpp
tokenpipe.h
trace.h Revert "tracepoints: Disables -Wgnu-zero-variadic-macro-arguments to compile without warnings" 2023-12-07 11:06:13 +01:00
transaction_identifier.h Add transaction_identifier::size to allow Span conversion 2024-02-27 14:19:15 +00:00
translation.h refactor: Avoid copy of bilingual_str when formatting, Fix ADL violation 2023-06-15 16:21:29 +02:00
types.h doc: Clarify C++20 comments 2024-01-05 11:22:31 +01:00
ui_change_type.h
vector.h chainparams: add blockhash to AssumeutxoData 2023-09-30 06:38:47 -04:00