Skip to content

Commit feb9bb1

Browse files
authored
Merge pull request kubernetes#75730 from wojtek-t/minor_perf_improvements
Avoid allocations in ByIndex() function
2 parents df9e666 + 7d46e27 commit feb9bb1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (c *threadSafeMap) ByIndex(indexName, indexKey string) ([]interface{}, erro
185185

186186
set := index[indexKey]
187187
list := make([]interface{}, 0, set.Len())
188-
for _, key := range set.List() {
188+
for key := range set {
189189
list = append(list, c.items[key])
190190
}
191191

test/utils/runners.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ func (config *RCConfig) start() error {
827827
if oldRunning != config.Replicas {
828828
// List only pods from a given replication controller.
829829
options := metav1.ListOptions{LabelSelector: label.String()}
830-
if pods, err := config.Client.CoreV1().Pods(metav1.NamespaceAll).List(options); err == nil {
830+
if pods, err := config.Client.CoreV1().Pods(config.Namespace).List(options); err == nil {
831831
for _, pod := range pods.Items {
832832
config.RCConfigLog("Pod %s\t%s\t%s\t%s", pod.Name, pod.Spec.NodeName, pod.Status.Phase, pod.DeletionTimestamp)
833833
}

0 commit comments

Comments
 (0)