Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
fix: avoid allocating cids (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien authored Apr 13, 2020
1 parent a8af17a commit 906b2fb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion message/pb/cid.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ func (c Cid) Marshal() ([]byte, error) {
}

func (c *Cid) MarshalTo(data []byte) (int, error) {
return copy(data[:c.Size()], c.Cid.Bytes()), nil
// intentionally using KeyString here to avoid allocating.
return copy(data[:c.Size()], c.Cid.KeyString()), nil
}

func (c *Cid) Unmarshal(data []byte) (err error) {
Expand Down

0 comments on commit 906b2fb

Please sign in to comment.