From 5305afb54345d082e5b370b048666eae54f444e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8A=E6=9D=89=E5=A4=8F=E9=A6=99?= <390047718@qq.com> Date: Thu, 4 Jul 2024 23:12:09 +0800 Subject: [PATCH] fix:remove the duplicate code --- fastcache.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fastcache.go b/fastcache.go index 046af6c..1a6d3ec 100644 --- a/fastcache.go +++ b/fastcache.go @@ -246,7 +246,6 @@ func (b *bucket) Init(maxBytes uint64) { } maxChunks := (maxBytes + chunkSize - 1) / chunkSize b.chunks = make([][]byte, maxChunks) - b.m = make(map[uint64]uint64) b.Reset() } @@ -260,11 +259,11 @@ func (b *bucket) Reset() { b.m = make(map[uint64]uint64) b.idx = 0 b.gen = 1 - atomic.StoreUint64(&b.getCalls, 0) - atomic.StoreUint64(&b.setCalls, 0) - atomic.StoreUint64(&b.misses, 0) - atomic.StoreUint64(&b.collisions, 0) - atomic.StoreUint64(&b.corruptions, 0) + b.getCalls = 0 + b.setCalls = 0 + b.misses = 0 + b.collisions = 0 + b.corruptions = 0 b.mu.Unlock() }