Skip to content

Commit

Permalink
unneeded clocking from lru cache
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Mar 30, 2024
1 parent 2c28769 commit 7772829
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions lru_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package lru

import (
"sync/atomic"
"unsafe"
)

Expand Down Expand Up @@ -133,9 +132,8 @@ func (c *LRUCache[K, V]) Len() int {

// AppendKeys appends all keys to keys and return the keys.
func (c *LRUCache[K, V]) AppendKeys(keys []K) []K {
now := atomic.LoadUint32(&clock)
for i := uint32(0); i <= c.mask; i++ {
keys = c.shards[i].AppendKeys(keys, now)
keys = c.shards[i].AppendKeys(keys)
}
return keys
}
Expand Down
2 changes: 1 addition & 1 deletion lru_shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (s *lrushard[K, V]) Len() (n uint32) {
return
}

func (s *lrushard[K, V]) AppendKeys(dst []K, now uint32) []K {
func (s *lrushard[K, V]) AppendKeys(dst []K) []K {
s.mu.Lock()
for _, bucket := range s.table_buckets {
b := (*lrubucket)(unsafe.Pointer(&bucket))
Expand Down

0 comments on commit 7772829

Please sign in to comment.