mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-18 19:40:40 +01:00
compressor: use a prevector in compressed script serialization
Use a prevector for stack allocation instead of heap allocation during script compression and decompression. These functions were doing millions of unnecessary heap allocations during IBD. We introduce a CompressedScript type alias for this prevector. It is size 33 as that is the maximum size of a compressed script. Fix the DecompressScript header to match the variable name from compressor.cpp Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -52,7 +52,7 @@ static bool IsToPubKey(const CScript& script, CPubKey &pubkey)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CompressScript(const CScript& script, std::vector<unsigned char> &out)
|
||||
bool CompressScript(const CScript& script, CompressedScript& out)
|
||||
{
|
||||
CKeyID keyID;
|
||||
if (IsToKeyID(script, keyID)) {
|
||||
@@ -92,7 +92,7 @@ unsigned int GetSpecialScriptSize(unsigned int nSize)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DecompressScript(CScript& script, unsigned int nSize, const std::vector<unsigned char> &in)
|
||||
bool DecompressScript(CScript& script, unsigned int nSize, const CompressedScript& in)
|
||||
{
|
||||
switch(nSize) {
|
||||
case 0x00:
|
||||
|
||||
Reference in New Issue
Block a user