mirror of
https://github.com/xtaci/kcp-go.git
synced 2026-10-19 16:14:38 +00:00
use any to substitute interface{}
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ type bufferPool struct {
|
||||
func newBufferPool(size int) *bufferPool {
|
||||
return &bufferPool{
|
||||
xmitBuf: sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return make([]byte, size)
|
||||
},
|
||||
},
|
||||
|
||||
@@ -84,12 +84,12 @@ func (h *shardHeap) Less(i, j int) bool {
|
||||
}
|
||||
|
||||
func (h *shardHeap) Swap(i, j int) { h.elements[i], h.elements[j] = h.elements[j], h.elements[i] }
|
||||
func (h *shardHeap) Push(x interface{}) {
|
||||
func (h *shardHeap) Push(x any) {
|
||||
h.elements = append(h.elements, x.(fecPacket))
|
||||
h.marks[x.(fecPacket).seqid()] = struct{}{}
|
||||
}
|
||||
|
||||
func (h *shardHeap) Pop() interface{} {
|
||||
func (h *shardHeap) Pop() any {
|
||||
n := len(h.elements)
|
||||
x := h.elements[n-1]
|
||||
h.elements = h.elements[0 : n-1]
|
||||
|
||||
@@ -180,12 +180,12 @@ func (h *segmentHeap) Less(i, j int) bool {
|
||||
}
|
||||
|
||||
func (h *segmentHeap) Swap(i, j int) { h.segments[i], h.segments[j] = h.segments[j], h.segments[i] }
|
||||
func (h *segmentHeap) Push(x interface{}) {
|
||||
func (h *segmentHeap) Push(x any) {
|
||||
h.segments = append(h.segments, x.(segment))
|
||||
h.marks[x.(segment).sn] = struct{}{}
|
||||
}
|
||||
|
||||
func (h *segmentHeap) Pop() interface{} {
|
||||
func (h *segmentHeap) Pop() any {
|
||||
n := len(h.segments)
|
||||
x := h.segments[n-1]
|
||||
h.segments = h.segments[0 : n-1]
|
||||
|
||||
+5
-5
@@ -40,11 +40,11 @@ type timedFunc struct {
|
||||
// a heap for sorted timed function
|
||||
type timedFuncHeap []timedFunc
|
||||
|
||||
func (h timedFuncHeap) Len() int { return len(h) }
|
||||
func (h timedFuncHeap) Less(i, j int) bool { return h[i].ts.Before(h[j].ts) }
|
||||
func (h timedFuncHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
|
||||
func (h *timedFuncHeap) Push(x interface{}) { *h = append(*h, x.(timedFunc)) }
|
||||
func (h *timedFuncHeap) Pop() interface{} {
|
||||
func (h timedFuncHeap) Len() int { return len(h) }
|
||||
func (h timedFuncHeap) Less(i, j int) bool { return h[i].ts.Before(h[j].ts) }
|
||||
func (h timedFuncHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
|
||||
func (h *timedFuncHeap) Push(x any) { *h = append(*h, x.(timedFunc)) }
|
||||
func (h *timedFuncHeap) Pop() any {
|
||||
old := *h
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
|
||||
Reference in New Issue
Block a user