From 4b55bb3e68a75de12a68b62d2a04490c112c5f2d Mon Sep 17 00:00:00 2001 From: ronanh Date: Thu, 7 Sep 2023 14:41:05 +0200 Subject: [PATCH] perf: Alloc records in batch (#2646) Signed-off-by: Ronan Harmegnies --- record_batch.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/record_batch.go b/record_batch.go index d382ca488..c6f41b27a 100644 --- a/record_batch.go +++ b/record_batch.go @@ -20,12 +20,12 @@ func (e recordsArray) encode(pe packetEncoder) error { } func (e recordsArray) decode(pd packetDecoder) error { + records := make([]Record, len(e)) for i := range e { - rec := &Record{} - if err := rec.decode(pd); err != nil { + if err := records[i].decode(pd); err != nil { return err } - e[i] = rec + e[i] = &records[i] } return nil }