Skip to content

Commit

Permalink
Remove smallest key from list of keys
Browse files Browse the repository at this point in the history
  • Loading branch information
s-barr-fetch committed Feb 9, 2024
1 parent 99dbf0c commit 8c35b9c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,11 +608,15 @@ func (db *RedisDB) setIntercard(keys []string, limit int) (int, error) {
}

smallestKey := keys[0]
for _, key := range keys {
smallestIdx := 0
for i, key := range keys {
if len(db.setKeys[key]) < len(db.setKeys[smallestKey]) {
smallestKey = key
smallestIdx = i
}
}
keys[smallestIdx] = keys[len(keys)-1]
keys = keys[:len(keys)-1]

count := 0
for item, _ := range db.setKeys[smallestKey] {
Expand Down

0 comments on commit 8c35b9c

Please sign in to comment.