ipfs / go-cid

Content ID v1 implemented in go
MIT License
156 stars 47 forks source link

avoid double alloc in NewCidV1 #132

Closed mvdan closed 3 years ago

mvdan commented 3 years ago

(see commit message)

mvdan commented 3 years ago

Possibly? I guess it's a tradeoff between "copy uvarint bytes around" and "use more stack space and possibly allocate if our stack space isn't big enough". It's hard to make the call without stats. I think that copying the PutUvarint bytes (most likely just a few bytes, max 10) is cheap enough that we shouldn't pay any attention to it :) The new NewCidV1 is faster than the old one, anyway.