Skip to content

Commit e540ebe

Browse files
MbolotSusek8s-publishing-bot
authored andcommitted
Addresses the issue which caused #109115
Kubernetes-commit: cbbb5f70a47644f9830073d9d0329bf247a328a1
1 parent 1cab689 commit e540ebe

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

tools/cache/thread_safe_store.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -280,18 +280,15 @@ func (c *threadSafeMap) updateIndices(oldObj interface{}, newObj interface{}, ke
280280
c.indices[name] = index
281281
}
282282

283+
if len(indexValues) == 1 && len(oldIndexValues) == 1 && indexValues[0] == oldIndexValues[0] {
284+
// We optimize for the most common case where indexFunc returns a single value which has not been changed
285+
continue
286+
}
287+
283288
for _, value := range oldIndexValues {
284-
// We optimize for the most common case where indexFunc returns a single value.
285-
if len(indexValues) == 1 && value == indexValues[0] {
286-
continue
287-
}
288289
c.deleteKeyFromIndex(key, value, index)
289290
}
290291
for _, value := range indexValues {
291-
// We optimize for the most common case where indexFunc returns a single value.
292-
if len(oldIndexValues) == 1 && value == oldIndexValues[0] {
293-
continue
294-
}
295292
c.addKeyToIndex(key, value, index)
296293
}
297294
}

0 commit comments

Comments
 (0)