aboutsummaryrefslogtreecommitdiff
path: root/src/pubkey.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-10-28 17:50:04 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2016-11-07 13:56:27 -0800
commit25a211aa9edfeccc1e65bf699e0b32619cef2157 (patch)
tree07345f3d4cc10cd2d2c3419a6074a41c99bb20f2 /src/pubkey.h
parenta2929a26f5cf3501804fd12071dd6cf6b464a545 (diff)
Add optimized CSizeComputer serializers
To get the advantages of faster GetSerializeSize() implementations back that were removed in "Make GetSerializeSize a wrapper on top of CSizeComputer", reintroduce them in the few places in the form of a specialized Serialize() implementation. This actually gets us in a better state than before, as these even get used when they're invoked indirectly in the serialization of another object.
Diffstat (limited to 'src/pubkey.h')
-rw-r--r--src/pubkey.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/pubkey.h b/src/pubkey.h
index 15207f89e1..9499862210 100644
--- a/src/pubkey.h
+++ b/src/pubkey.h
@@ -210,6 +210,11 @@ struct CExtPubKey {
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE]);
bool Derive(CExtPubKey& out, unsigned int nChild) const;
+ void Serialize(CSizeComputer& s) const
+ {
+ // Optimized implementation for ::GetSerializeSize that avoids copying.
+ s.seek(BIP32_EXTKEY_SIZE + 1); // add one byte for the size (compact int)
+ }
template <typename Stream>
void Serialize(Stream& s) const
{