From 20e683ef26b9a4744d85df5d4f735de7b0f598ca Mon Sep 17 00:00:00 2001 From: Ronan Harmegnies Date: Sun, 3 Sep 2023 10:13:39 +0200 Subject: [PATCH] perf: Alloc records in batch 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 }