recycle json decoder

This commit is contained in:
2025-08-23 12:36:36 +02:00
parent 713a6bd6be
commit 16d2e8e8fd

View File

@ -77,9 +77,11 @@ func readSocketGeneric[T any](ctx context.Context, socket string, body io.Reader
defer close(out)
defer r.Close()
dec := json.NewDecoder(r)
for ctx.Err() == nil {
value := new(T)
if err := json.NewDecoder(r).Decode(value); err != nil {
if err := dec.Decode(value); err != nil {
if errors.Is(err, io.EOF) {
return
} else {