sorting incoming packet ids is redundant
Having this outside the worker pool means tcp will ensure packet
ordering is consistent with what the client sent.
diff --git a/packet-manager.go b/packet-manager.go
index cc14fb5..3ac1182 100644
--- a/packet-manager.go
+++ b/packet-manager.go
@@ -29,7 +29,7 @@
requests chan requestPacket
responses chan responsePacket
fini chan struct{}
- incoming uint32s
+ incoming []uint32
outgoing responsePackets
sender packetSender // connection object
}
@@ -48,13 +48,8 @@
}
// for sorting/ordering incoming/outgoing
-type uint32s []uint32
type responsePackets []responsePacket
-func (u uint32s) Len() int { return len(u) }
-func (u uint32s) Swap(i, j int) { u[i], u[j] = u[j], u[i] }
-func (u uint32s) Less(i, j int) bool { return u[i] < u[j] }
-
func (r responsePackets) Len() int { return len(r) }
func (r responsePackets) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
func (r responsePackets) Less(i, j int) bool { return r[i].id() < r[j].id() }
@@ -82,9 +77,6 @@
case pkt := <-s.requests:
debug("incoming id: %v", pkt.id())
s.incoming = append(s.incoming, pkt.id())
- if len(s.incoming) > 1 {
- sort.Sort(s.incoming)
- }
case pkt := <-s.responses:
debug("outgoing pkt: %v", pkt.id())
s.outgoing = append(s.outgoing, pkt)