Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added counters.Reader.ScanUnsafe to avoid allocations
Calls to counters.Reader.Scan were allocating heap that would be released after each call. Reader.labelValue's call to atomic.Buffer.GetBytesArray is make'ing a []byte and then labelValue would construct a string from that allocation again. Added ScanUnsafe for a code path that doesn't allocate. It shares scan with Scan and scan reuses a []byte on each call. Scan copies it to a string which allocates, but remains worry free. ScanUnsafe casts the slice to a string that is not safe to retain outside the callback.
- Loading branch information