Skip to content

Commit

Permalink
Fix comment and remove unneeded allocation (#2919)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Apr 5, 2024
1 parent 4a1d0bb commit 323d03b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions x/merkledb/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,14 @@ func (c *onEvictCache[K, V]) Put(key K, value V) error {
}

// Flush removes all elements from the cache.
// Returns the last non-nil error during [c.onEviction], if any.
// If [c.onEviction] errors, it will still be called for any
// subsequent elements and the cache will still be emptied.
//
// Returns the first non-nil error returned by [c.onEviction], if any.
//
// If [c.onEviction] errors, it will still be called for any subsequent elements
// and the cache will still be emptied.
func (c *onEvictCache[K, V]) Flush() error {
c.lock.Lock()
defer func() {
c.fifo = linked.NewHashmap[K, V]()
c.lock.Unlock()
}()
defer c.lock.Unlock()

return c.resize(0)
}
Expand Down

0 comments on commit 323d03b

Please sign in to comment.