Skip to content

Commit

Permalink
UPSTREAM: 109137: Addresses the issue which caused kubernetes#109115
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kuznetsov <[email protected]>
  • Loading branch information
MbolotSuse authored and stevekuznetsov committed Jul 11, 2022
1 parent 1f64936 commit d351993
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions staging/src/k8s.io/client-go/tools/cache/thread_safe_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,18 +284,15 @@ func (c *threadSafeMap) updateIndices(oldObj interface{}, newObj interface{}, ke
c.indices[name] = index
}

if len(indexValues) == 1 && len(oldIndexValues) == 1 && indexValues[0] == oldIndexValues[0] {
// We optimize for the most common case where indexFunc returns a single value which has not been changed
continue
}

for _, value := range oldIndexValues {
// We optimize for the most common case where index returns a single value.
if len(indexValues) == 1 && value == indexValues[0] {
continue
}
c.deleteKeyFromIndex(key, value, index)
}
for _, value := range indexValues {
// We optimize for the most common case where index returns a single value.
if len(oldIndexValues) == 1 && value == oldIndexValues[0] {
continue
}
c.addKeyToIndex(key, value, index)
}
}
Expand Down

0 comments on commit d351993

Please sign in to comment.