Skip to content

Commit d351993

Browse files
MbolotSusestevekuznetsov
authored andcommitted
UPSTREAM: 109137: Addresses the issue which caused kubernetes#109115
Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent 1f64936 commit d351993

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

staging/src/k8s.io/client-go/tools/cache/thread_safe_store.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,15 @@ func (c *threadSafeMap) updateIndices(oldObj interface{}, newObj interface{}, ke
284284
c.indices[name] = index
285285
}
286286

287+
if len(indexValues) == 1 && len(oldIndexValues) == 1 && indexValues[0] == oldIndexValues[0] {
288+
// We optimize for the most common case where indexFunc returns a single value which has not been changed
289+
continue
290+
}
291+
287292
for _, value := range oldIndexValues {
288-
// We optimize for the most common case where index returns a single value.
289-
if len(indexValues) == 1 && value == indexValues[0] {
290-
continue
291-
}
292293
c.deleteKeyFromIndex(key, value, index)
293294
}
294295
for _, value := range indexValues {
295-
// We optimize for the most common case where index returns a single value.
296-
if len(oldIndexValues) == 1 && value == oldIndexValues[0] {
297-
continue
298-
}
299296
c.addKeyToIndex(key, value, index)
300297
}
301298
}

0 commit comments

Comments
 (0)