Skip to content

Commit 735b607

Browse files
authored
Merge pull request #2614 from k8s-infra-cherrypick-robot/cherry-pick-2529-to-release-0.15
[release-0.15] 🏃 Make client.MatchingLabels faster
2 parents 9a0ec0f + f0320e6 commit 735b607

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/client/options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ type MatchingLabels map[string]string
514514
func (m MatchingLabels) ApplyToList(opts *ListOptions) {
515515
// TODO(directxman12): can we avoid reserializing this over and over?
516516
if opts.LabelSelector == nil {
517-
opts.LabelSelector = labels.NewSelector()
517+
opts.LabelSelector = labels.SelectorFromValidatedSet(map[string]string(m))
518+
return
518519
}
519520
// If there's already a selector, we need to AND the two together.
520521
noValidSel := labels.SelectorFromValidatedSet(map[string]string(m))

0 commit comments

Comments
 (0)