allocations improvements and tunnel fixes (#1248)
* reduce allocations in tunnel code Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * another allocation fix Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * allocate maps with len if it known Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * allocate key for send once Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
f727b75b6f
commit
78d2884ced
2
codec.go
2
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, ",")
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user