use any to substitute interface{}

This commit is contained in:
xtaci
2025-11-21 16:24:14 +08:00
parent 8bfedf16d1
commit 91e7483fc9
4 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -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)
},
},
+2 -2
View File
@@ -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]
+2 -2
View File
@@ -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
View File
@@ -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]