Skip to content

Commit

Permalink
Use empty struct for set using map instead of interface{}.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxki committed Sep 29, 2023
1 parent 88606b8 commit e8bef4b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/cache/res_cache_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (r *ResponseCacheStore) Update(caches []ResponseCache) []ResponseCache {
}

cacheMap := make(map[string]ResponseCache, len(caches))
duplMap := make(map[string]interface{}, len(caches))
duplSet := make(map[string]struct{}, len(caches))

for idx := range caches {
// Check if it is possible to retrieve the serial number
Expand All @@ -66,7 +66,7 @@ func (r *ResponseCacheStore) Update(caches []ResponseCache) []ResponseCache {
}

// Check not dupulicated
if _, ok := duplMap[key]; ok {
if _, ok := duplSet[key]; ok {
invalids = append(invalids, caches[idx])
continue
}
Expand All @@ -75,7 +75,7 @@ func (r *ResponseCacheStore) Update(caches []ResponseCache) []ResponseCache {
invalids = append(invalids, cacheMap[key])
invalids = append(invalids, caches[idx])
delete(cacheMap, key)
duplMap[key] = nil
duplSet[key] = struct{}{}
continue
}

Expand Down

0 comments on commit e8bef4b

Please sign in to comment.