google / uuid

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.
BSD 3-Clause "New" or "Revised" License
5.24k stars 363 forks source link

Reduce custom error allocation #70

Closed johejo closed 3 years ago

johejo commented 3 years ago

Zero allocation by using non-pointer error.

related #69

name               old time/op    new time/op    delta
ParseBadLength-16    15.4ns ± 0%     3.5ns ± 0%   ~     (p=1.000 n=1+1)

name               old alloc/op   new alloc/op   delta
ParseBadLength-16     8.00B ± 0%     0.00B        ~     (p=1.000 n=1+1)

name               old allocs/op  new allocs/op  delta
ParseBadLength-16      1.00 ± 0%      0.00        ~     (p=1.000 n=1+1)
pborman commented 3 years ago

Thanks, this is a good optimization.

taadis commented 3 years ago

why?