2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-26 07:42:17 +08:00

fix: queues map init with size (#673)

Co-authored-by: yipinhe <yipinhe@tencent.com>
This commit is contained in:
ghosx 2024-11-11 13:25:42 +08:00 committed by GitHub
parent 1a7c61ac49
commit d2c207fbb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -375,7 +375,7 @@ func EncodeServerInfo(info *ServerInfo) ([]byte, error) {
if info == nil { if info == nil {
return nil, fmt.Errorf("cannot encode nil server info") 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 { for q, p := range info.Queues {
queues[q] = int32(p) queues[q] = int32(p)
} }
@ -400,7 +400,7 @@ func DecodeServerInfo(b []byte) (*ServerInfo, error) {
if err := proto.Unmarshal(b, &pbmsg); err != nil { if err := proto.Unmarshal(b, &pbmsg); err != nil {
return nil, err return nil, err
} }
queues := make(map[string]int) queues := make(map[string]int, len(pbmsg.GetQueues()))
for q, p := range pbmsg.GetQueues() { for q, p := range pbmsg.GetQueues() {
queues[q] = int(p) queues[q] = int(p)
} }