Commit Graph

1 Commits

Author SHA1 Message Date
Vu Dinh
380c17ea0b Use MapIter.SetKey/SetValue and sync.Pool to improve memory allocation
Since go 1.18, the reflect package introduces MapIter.SetKey and
MapIter.SetValue that will do fewer memory allocation for map
iteration which is frequently used for CBOR encode operation. Plus,
usage of sync.Pool will further reduce memory allocation by reusing
the shared memory in the pool. Lastly, the Value.SetZero method
(available since go 1.20) is helpful to release memory allocation
to the GC when is no longer needed.

Signed-off-by: Vu Dinh <vudinh@outlook.com>
2024-01-23 18:33:34 -05:00