mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Merge bitcoin/bitcoin#18847: compressor: use a prevector in CompressScript serialization [ZAP1]
83a425d25acompressor: use a prevector in compressed script serialization (William Casarin) Pull request description: This function was doing millions of unnecessary heap allocations during IBD. I'm start to catalog unnecessary heap allocations as a pet project of mine: as-zero-as-possible-alloc IBD. This is one small step. before:  after:  ~should I type alias this?~ *I type aliased it* This is a part of the Zero Allocations Project #18849 (ZAP1). This code came up as a place where many allocations occur. ACKs for top commit: Empact: ACK83a425d25aelichai: tACK83a425d25asipa: utACK83a425d25aTree-SHA512: f0ffa6ab0ea1632715b0b76362753f9f6935f05cdcc80d85566774401155a3c57ad45a687942a1806d3503858f0bb698da9243746c8e2edb8fdf13611235b0e0
This commit is contained in:
@@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(compress_script_to_ckey_id)
|
||||
CScript script = CScript() << OP_DUP << OP_HASH160 << ToByteVector(pubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
BOOST_CHECK_EQUAL(script.size(), 25U);
|
||||
|
||||
std::vector<unsigned char> out;
|
||||
CompressedScript out;
|
||||
bool done = CompressScript(script, out);
|
||||
BOOST_CHECK_EQUAL(done, true);
|
||||
|
||||
@@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE(compress_script_to_cscript_id)
|
||||
script << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
|
||||
BOOST_CHECK_EQUAL(script.size(), 23U);
|
||||
|
||||
std::vector<unsigned char> out;
|
||||
CompressedScript out;
|
||||
bool done = CompressScript(script, out);
|
||||
BOOST_CHECK_EQUAL(done, true);
|
||||
|
||||
@@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE(compress_script_to_compressed_pubkey_id)
|
||||
CScript script = CScript() << ToByteVector(key.GetPubKey()) << OP_CHECKSIG; // COMPRESSED_PUBLIC_KEY_SIZE (33)
|
||||
BOOST_CHECK_EQUAL(script.size(), 35U);
|
||||
|
||||
std::vector<unsigned char> out;
|
||||
CompressedScript out;
|
||||
bool done = CompressScript(script, out);
|
||||
BOOST_CHECK_EQUAL(done, true);
|
||||
|
||||
@@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(compress_script_to_uncompressed_pubkey_id)
|
||||
CScript script = CScript() << ToByteVector(key.GetPubKey()) << OP_CHECKSIG; // PUBLIC_KEY_SIZE (65)
|
||||
BOOST_CHECK_EQUAL(script.size(), 67U); // 1 char code + 65 char pubkey + OP_CHECKSIG
|
||||
|
||||
std::vector<unsigned char> out;
|
||||
CompressedScript out;
|
||||
bool done = CompressScript(script, out);
|
||||
BOOST_CHECK_EQUAL(done, true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user