mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
common/lru: shorten return names
This commit is contained in:
parent
1c64c74f07
commit
b04157fafe
1 changed files with 7 additions and 7 deletions
|
|
@ -52,32 +52,32 @@ func (c *BasicLRU[K, V]) Add(key K, value V) (evicted bool) {
|
|||
}
|
||||
|
||||
// Add3 adds a value to the cache. If an item was evicted to store the new one, it returns the evicted item.
|
||||
func (c *BasicLRU[K, V]) Add3(key K, value V) (evKey K, evItem V, evicted bool) {
|
||||
func (c *BasicLRU[K, V]) Add3(key K, value V) (ek K, ev V, evicted bool) {
|
||||
item, ok := c.items[key]
|
||||
if ok {
|
||||
item.value = value
|
||||
c.items[key] = item
|
||||
c.list.moveToFront(item.elem)
|
||||
return evKey, evItem, false
|
||||
return ek, ev, false
|
||||
}
|
||||
|
||||
var elem *listElem[K]
|
||||
if c.Len() >= c.cap {
|
||||
elem = c.list.removeLast()
|
||||
evicted = true
|
||||
evKey = elem.v
|
||||
evItem = c.items[evKey].value
|
||||
delete(c.items, evKey)
|
||||
ek = elem.v
|
||||
ev = c.items[ek].value
|
||||
delete(c.items, ek)
|
||||
} else {
|
||||
elem = new(listElem[K])
|
||||
}
|
||||
|
||||
// Store the new item.
|
||||
// Note that, if another item was evicted, we re-use its list element here.
|
||||
// Note that if another item was evicted, we re-use its list element here.
|
||||
elem.v = key
|
||||
c.items[key] = cacheItem[K, V]{elem, value}
|
||||
c.list.pushElem(elem)
|
||||
return evKey, evItem, evicted
|
||||
return ek, ev, evicted
|
||||
}
|
||||
|
||||
// Contains reports whether the given key exists in the cache.
|
||||
|
|
|
|||
Loading…
Reference in a new issue