Commit 628a0123 authored by Eric Myhre's avatar Eric Myhre

Slightly more documentation comment.

parent 266e76d5
......@@ -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)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment