delete invalid copy (#1573)

* prealloc

* delete invalid copy
This commit is contained in:
徐旭 2020-04-26 19:44:59 +08:00 committed by GitHub
parent 0a030f3d8a
commit 7253635cd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,23 +67,9 @@ func (s *Socket) Local() string {
}
func (s *Socket) Send(m *transport.Message) error {
// make copy
msg := &transport.Message{
Header: make(map[string]string),
Body: make([]byte, len(m.Body)),
}
// copy headers
for k, v := range m.Header {
msg.Header[k] = v
}
// copy body
copy(msg.Body, m.Body)
// send a message
select {
case s.send <- msg:
case s.send <- m:
case <-s.closed:
return io.EOF
}