From 628a0123edd1a79d4df35ea06abff2e2456fd389 Mon Sep 17 00:00:00 2001 From: Eric Myhre Date: Sat, 2 May 2020 00:52:07 +0200 Subject: [PATCH] Slightly more documentation comment. --- cid.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cid.go b/cid.go index becf6e8..9955b09 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) } -- GitLab