Skip to content

Commit

Permalink
Reuse msg in sendq internal loop, further reduces allocations
Browse files Browse the repository at this point in the history
Signed-off-by: Neil Twigg <neil@nats.io>
  • Loading branch information
neilalexander committed Nov 14, 2024
1 parent 36e4bbb commit 5fec935
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/sendq.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ func (sq *sendq) internalLoop() {
rply [256]byte
szb [10]byte
hdb [10]byte
_msg [4096]byte
msg = _msg[:0]
)

for s.isRunning() {
Expand All @@ -74,7 +76,7 @@ func (sq *sendq) internalLoop() {
} else {
c.pa.reply = nil
}
var msg []byte
msg = msg[:0]
if len(pm.hdr) > 0 {
c.pa.hdr = len(pm.hdr)
c.pa.hdb = append(hdb[:0], strconv.Itoa(c.pa.hdr)...)
Expand Down

0 comments on commit 5fec935

Please sign in to comment.