Skip to content

Commit 8ac8b9f

Browse files
authored
Merge pull request #2529 from kubernetes-sigs/speed-up
🏃 Make client.MatchingLabels faster
2 parents 968daa8 + cb5be1f commit 8ac8b9f

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)