From 02e0f9c5fdb61fcd5d53943713eb880cbb789a27 Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Mon, 8 Apr 2019 13:22:26 -0700 Subject: [PATCH] Produce map according to the shorter array in haveOverlap --- pkg/scheduler/algorithm/predicates/predicates.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/scheduler/algorithm/predicates/predicates.go b/pkg/scheduler/algorithm/predicates/predicates.go index 2a8783c35d4..faa9e79a20f 100644 --- a/pkg/scheduler/algorithm/predicates/predicates.go +++ b/pkg/scheduler/algorithm/predicates/predicates.go @@ -1095,6 +1095,9 @@ func PodFitsHostPorts(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulerno // search two arrays and return true if they have at least one common element; return false otherwise func haveOverlap(a1, a2 []string) bool { + if len(a1) > len(a2) { + a1, a2 = a2, a1 + } m := map[string]bool{} for _, val := range a1 {