From ab90fa8928151554324f07f27126ddb104682bb2 Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Tue, 22 Aug 2023 14:06:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=20go1.21=20=E4=BB=A5?= =?UTF-8?q?=E4=B8=8B=E9=A1=B9=E7=9B=AE=E7=9A=84=E5=85=BC=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/counter/counter.go | 7 ++++--- utils/slice/priority.go | 2 +- utils/sole/once.go | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/utils/counter/counter.go b/utils/counter/counter.go index 5ef7f05..922a6db 100644 --- a/utils/counter/counter.go +++ b/utils/counter/counter.go @@ -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() } diff --git a/utils/slice/priority.go b/utils/slice/priority.go index b44f3e9..ecdac20 100644 --- a/utils/slice/priority.go +++ b/utils/slice/priority.go @@ -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 添加元素 diff --git a/utils/sole/once.go b/utils/sole/once.go index 9452d05..9d06def 100644 --- a/utils/sole/once.go +++ b/utils/sole/once.go @@ -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) }