Trim UDP tracker client read allocations
This commit is contained in:
parent
1d53c170b0
commit
83749028ec
|
@ -23,8 +23,8 @@ type ConnClient struct {
|
|||
}
|
||||
|
||||
func (cc *ConnClient) reader() {
|
||||
b := make([]byte, 0x800)
|
||||
for {
|
||||
b := make([]byte, 0x800)
|
||||
n, err := cc.conn.Read(b)
|
||||
if err != nil {
|
||||
// TODO: Do bad things to the dispatcher, and incoming calls to the client if we have a
|
||||
|
|
|
@ -11,6 +11,7 @@ type Dispatcher struct {
|
|||
transactions map[TransactionId]Transaction
|
||||
}
|
||||
|
||||
// The caller owns b.
|
||||
func (me *Dispatcher) Dispatch(b []byte) error {
|
||||
buf := bytes.NewBuffer(b)
|
||||
var rh ResponseHeader
|
||||
|
@ -23,7 +24,7 @@ func (me *Dispatcher) Dispatch(b []byte) error {
|
|||
if t, ok := me.transactions[rh.TransactionId]; ok {
|
||||
t.h(DispatchedResponse{
|
||||
Header: rh,
|
||||
Body: buf.Bytes(),
|
||||
Body: append([]byte(nil), buf.Bytes()...),
|
||||
})
|
||||
return nil
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue