UniValue performance speedups for .write()
Summary:
Inspired by https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/commit/472118a0da52c480f18430cc97ea31950d48324e
with a number of fixups that:
- Improve internal linkage.
- Reduce code ownership where unnecessary ownership was taken.
- Keeps API reasonably consistent with original UniValue code.
- Various formatting, comments, and style fixes.
Depends on D5981 for the test plan
Test Plan:
ninja check check-functional
Run this before and after patch:
./src/bench/bitcoin-bench -filter=BlockToJsonVerbose
Observe ~3-4% speedup.
Verify internal linkage:
cmake -GNinja -DCMAKE_CXX_FLAGS="-emit-llvm -S" .. ninja univalue grep "define internal" src/univalue/libunivalue.a
I was only able to verify internal linkage for writeAny() and escapeJson(). Not the other UniValueStreamWriter functions.
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Subscribers: deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D5982