From c6b2a97ef4aa0f0a9f7fa056ca88cf7f2d4ecce7 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Sat, 8 Apr 2023 19:58:43 -0700 Subject: [PATCH] Use entry pool Signed-off-by: Derek Collison --- server/consumer.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/consumer.go b/server/consumer.go index f3ac3b04..066c600f 100644 --- a/server/consumer.go +++ b/server/consumer.go @@ -1721,7 +1721,7 @@ func newJSAckMsg(subj, reply string, hdr int, msg []byte) *jsAckMsg { } else { m = &jsAckMsg{} } - // When getting something from a pool it is criticical that all fields are + // When getting something from a pool it is critical that all fields are // initialized. Doing this way guarantees that if someone adds a field to // the structure, the compiler will fail the build if this line is not updated. (*m) = jsAckMsg{subj, reply, hdr, msg} @@ -1821,7 +1821,9 @@ func (o *consumer) loopAndForwardProposals(qch chan struct{}) { const maxBatch = 256 * 1024 var entries []*Entry for sz := 0; proposal != nil; proposal = proposal.next { - entries = append(entries, &Entry{EntryNormal, proposal.data}) + entry := entryPool.Get().(*Entry) + entry.Type, entry.Data = EntryNormal, proposal.data + entries = append(entries, entry) sz += len(proposal.data) if sz > maxBatch { node.ProposeDirect(entries)