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

fix: avoid allocating cids #348

Merged
merged 1 commit into from
Apr 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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