From 82009eb5db0ef0a2bc4a66eec6ac0dee116e5c54 Mon Sep 17 00:00:00 2001 From: PingWang Date: Fri, 13 May 2016 12:40:13 +0800 Subject: [PATCH] =?UTF-8?q?A=20optimization=20for=20=E2=80=9CRegisterCusto?= =?UTF-8?q?mFitPredicate=E2=80=9D=20function,=20avoiding=20redundancy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In RegisterCustomFitPredicate, when policy.Argument is nil and fitPredicateMap has the policy.Name, it can return the policy.Name directly. Subsequent operations are redundant. --- plugin/pkg/scheduler/factory/plugins.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/pkg/scheduler/factory/plugins.go b/plugin/pkg/scheduler/factory/plugins.go index 12350759718..e950543e34a 100644 --- a/plugin/pkg/scheduler/factory/plugins.go +++ b/plugin/pkg/scheduler/factory/plugins.go @@ -121,6 +121,7 @@ func RegisterCustomFitPredicate(policy schedulerapi.PredicatePolicy) string { } else if predicateFactory, ok = fitPredicateMap[policy.Name]; ok { // checking to see if a pre-defined predicate is requested glog.V(2).Infof("Predicate type %s already registered, reusing.", policy.Name) + return policy.Name } if predicateFactory == nil {