diff --git a/cid.go b/cid.go index becf6e89f81945fb144610c1a0f763af74ba2ada..9955b098938310f4be8920430baf2205610d3c03 100644 --- a/cid.go +++ b/cid.go @@ -409,12 +409,19 @@ func (c Cid) Bytes() []byte { return []byte(c.str) } -// ByteLen returns len(c.Bytes()) without an allocation +// ByteLen returns the length of the CID in bytes. +// It's equivalent to `len(c.Bytes())`, but works without an allocation, +// and should therefore be preferred. +// +// (See also the WriteTo method for other important operations that work without allocation.) func (c Cid) ByteLen() int { return len(c.str) } -// WriteTo writes the cids bytes to the given writer +// WriteTo writes the CID bytes to the given writer. +// This method works without incurring any allocation. +// +// (See also the ByteLen method for other important operations that work without allocation.) func (c Cid) WriteTo(w io.Writer) (int, error) { return io.WriteString(w, c.str) }