From 71d7d4952f75d65718c07bbc3c77522c5b71800e Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 22 May 2018 17:52:45 -0700 Subject: [PATCH] channeldb: remove premature buf.Grow optimization This optimization isn't needed as a bytes.Buffer already comes pre-allocated with 64-bytes as a fast path. --- channeldb/channel.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/channeldb/channel.go b/channeldb/channel.go index 36e30420..e815dbe9 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -536,7 +536,6 @@ func updateChanBucket(tx *bolt.Tx, nodeKey *btcec.PublicKey, // level, creating the bucket (if it doesn't exist), for this channel // itself. var chanPointBuf bytes.Buffer - chanPointBuf.Grow(outPointSize) if err := writeOutpoint(&chanPointBuf, outPoint); err != nil { return nil, fmt.Errorf("unable to write outpoint: %v", err) } @@ -582,7 +581,6 @@ func readChanBucket(tx *bolt.Tx, nodeKey *btcec.PublicKey, // With the bucket for the node fetched, we can now go down another // level, for this channel itself. var chanPointBuf bytes.Buffer - chanPointBuf.Grow(outPointSize) if err := writeOutpoint(&chanPointBuf, outPoint); err != nil { return nil, err } @@ -625,7 +623,6 @@ func (c *OpenChannel) fullSync(tx *bolt.Tx) error { // level, creating the bucket (if it doesn't exist), for this channel // itself. var chanPointBuf bytes.Buffer - chanPointBuf.Grow(outPointSize) if err := writeOutpoint(&chanPointBuf, &c.FundingOutpoint); err != nil { return err } @@ -1765,7 +1762,6 @@ func (c *OpenChannel) CloseChannel(summary *ChannelCloseSummary) error { } var chanPointBuf bytes.Buffer - chanPointBuf.Grow(outPointSize) err := writeOutpoint(&chanPointBuf, &c.FundingOutpoint) if err != nil { return err