From 7d46e27db185e5281b718ad964e9c2f8777c2fc8 Mon Sep 17 00:00:00 2001 From: wojtekt Date: Tue, 26 Mar 2019 14:14:42 +0100 Subject: [PATCH] Avoid allocations in ByIndex() function --- staging/src/k8s.io/client-go/tools/cache/thread_safe_store.go | 2 +- test/utils/runners.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/client-go/tools/cache/thread_safe_store.go b/staging/src/k8s.io/client-go/tools/cache/thread_safe_store.go index 5cbdd17ed45..b74faa019c5 100644 --- a/staging/src/k8s.io/client-go/tools/cache/thread_safe_store.go +++ b/staging/src/k8s.io/client-go/tools/cache/thread_safe_store.go @@ -185,7 +185,7 @@ func (c *threadSafeMap) ByIndex(indexName, indexKey string) ([]interface{}, erro set := index[indexKey] list := make([]interface{}, 0, set.Len()) - for _, key := range set.List() { + for key := range set { list = append(list, c.items[key]) } diff --git a/test/utils/runners.go b/test/utils/runners.go index 76e6f93462b..dc04d6d2ad3 100644 --- a/test/utils/runners.go +++ b/test/utils/runners.go @@ -827,7 +827,7 @@ func (config *RCConfig) start() error { if oldRunning != config.Replicas { // List only pods from a given replication controller. options := metav1.ListOptions{LabelSelector: label.String()} - if pods, err := config.Client.CoreV1().Pods(metav1.NamespaceAll).List(options); err == nil { + if pods, err := config.Client.CoreV1().Pods(config.Namespace).List(options); err == nil { for _, pod := range pods.Items { config.RCConfigLog("Pod %s\t%s\t%s\t%s", pod.Name, pod.Spec.NodeName, pod.Status.Phase, pod.DeletionTimestamp) }