diff --git a/codec.go b/codec.go index eb1b09c..db9706d 100644 --- a/codec.go +++ b/codec.go @@ -140,7 +140,7 @@ func (g *grpcCodec) ReadHeader(m *codec.Message, mt codec.MessageType) error { m = new(codec.Message) } if m.Header == nil { - m.Header = make(map[string]string) + m.Header = make(map[string]string, len(md)) } for k, v := range md { m.Header[k] = strings.Join(v, ",") diff --git a/subscriber.go b/subscriber.go index 7bd39a5..a29ebcb 100644 --- a/subscriber.go +++ b/subscriber.go @@ -188,7 +188,7 @@ func (g *grpcServer) createSubHandler(sb *subscriber, opts server.Options) broke return err } - hdr := make(map[string]string) + hdr := make(map[string]string, len(msg.Header)) for k, v := range msg.Header { hdr[k] = v }