From d2c207fbb8049549c01d5b3880e4fd76e8a2eb18 Mon Sep 17 00:00:00 2001 From: ghosx Date: Mon, 11 Nov 2024 13:25:42 +0800 Subject: [PATCH] fix: queues map init with size (#673) Co-authored-by: yipinhe --- internal/base/base.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/base/base.go b/internal/base/base.go index 4bbf30b..505e1ba 100644 --- a/internal/base/base.go +++ b/internal/base/base.go @@ -375,7 +375,7 @@ func EncodeServerInfo(info *ServerInfo) ([]byte, error) { if info == nil { return nil, fmt.Errorf("cannot encode nil server info") } - queues := make(map[string]int32) + queues := make(map[string]int32, len(info.Queues)) for q, p := range info.Queues { queues[q] = int32(p) } @@ -400,7 +400,7 @@ func DecodeServerInfo(b []byte) (*ServerInfo, error) { if err := proto.Unmarshal(b, &pbmsg); err != nil { return nil, err } - queues := make(map[string]int) + queues := make(map[string]int, len(pbmsg.GetQueues())) for q, p := range pbmsg.GetQueues() { queues[q] = int(p) }