fix: 优化 go1.21 以下项目的兼容性
This commit is contained in:
parent
a1c15a2c26
commit
ab90fa8928
|
@ -3,6 +3,7 @@ package counter
|
|||
import (
|
||||
"fmt"
|
||||
"github.com/kercylan98/minotaur/utils/generic"
|
||||
"github.com/kercylan98/minotaur/utils/hash"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
@ -151,9 +152,9 @@ func (slf *Counter[K, V]) ResetExpiredMark(mark, key K) {
|
|||
// ResetAll 重置所有计数
|
||||
func (slf *Counter[K, V]) ResetAll() {
|
||||
slf.lock.Lock()
|
||||
clear(slf.c)
|
||||
clear(slf.dr)
|
||||
clear(slf.drm)
|
||||
hash.Clear(slf.c)
|
||||
hash.Clear(slf.dr)
|
||||
hash.Clear(slf.drm)
|
||||
slf.lock.Unlock()
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ func (slf *Priority[V]) Cap() int {
|
|||
|
||||
// Clear 清空切片
|
||||
func (slf *Priority[V]) Clear() {
|
||||
clear(slf.items)
|
||||
slf.items = slf.items[:0]
|
||||
}
|
||||
|
||||
// Append 添加元素
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package sole
|
||||
|
||||
import "github.com/kercylan98/minotaur/utils/hash"
|
||||
|
||||
// NewOnce 创建一个用于数据取值去重的结构实例
|
||||
func NewOnce[V any]() *Once[V] {
|
||||
once := &Once[V]{
|
||||
|
@ -31,5 +33,5 @@ func (slf *Once[V]) Reset(key ...any) {
|
|||
}
|
||||
return
|
||||
}
|
||||
clear(slf.r)
|
||||
hash.Clear(slf.r)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue