From 45c31795e747caff3be1df278c7c60072c5edd18 Mon Sep 17 00:00:00 2001 From: mleku Date: Fri, 12 Sep 2025 16:25:37 +0100 Subject: [PATCH] Simplify buffer allocation logic in event encoding by adjusting size calculations for improved performance and reduced complexity. --- pkg/encoders/event/event.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/encoders/event/event.go b/pkg/encoders/event/event.go index 9b1786a..49a7dbc 100644 --- a/pkg/encoders/event/event.go +++ b/pkg/encoders/event/event.go @@ -121,7 +121,7 @@ func (ev *E) Marshal(dst []byte) (b []byte) { // integrates properly with the buffer pool, reducing GC pressure and // avoiding new heap allocations. if cap(b) < len(b)+len(ev.Content)+7+256+2 { - b2 := make([]byte, len(b)+len(ev.Content)*2+7+256+2) + b2 := make([]byte, len(b)+len(ev.Content)*2+512) copy(b2, b) b2 = b2[:len(b)] // return the old buffer to the pool for reuse.