-
Notifications
You must be signed in to change notification settings - Fork 189
fix:remove the duplicate code #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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.collisions = 0 | |
| atomic.StoreUint64(&b.collisions, 0) |
Copilot
AI
Jul 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Direct assignment to b.corruptions may cause race conditions if other goroutines read this field concurrently without holding the mutex. If corruptions is accessed outside the mutex elsewhere in the code, atomic operations should be retained.
| b.corruptions = 0 | |
| atomic.StoreUint64(&b.corruptions, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Direct assignment to b.getCalls may cause race conditions if other goroutines read this field concurrently without holding the mutex. If getCalls is accessed outside the mutex elsewhere in the code, atomic operations should be retained.