From 2db9dc48113b1a868ab3088a6a4c7548f304fb34 Mon Sep 17 00:00:00 2001 From: qinguoyi <1532979219@qq.com> Date: Wed, 7 Aug 2024 22:17:28 +0800 Subject: [PATCH] chore:clean up Signed-off-by: qinguoyi <1532979219@qq.com> --- .../core/spreadconstraint/select_groups.go | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/pkg/scheduler/core/spreadconstraint/select_groups.go b/pkg/scheduler/core/spreadconstraint/select_groups.go index 7afbe67cc..069d7096f 100755 --- a/pkg/scheduler/core/spreadconstraint/select_groups.go +++ b/pkg/scheduler/core/spreadconstraint/select_groups.go @@ -158,26 +158,21 @@ func findFeasiblePaths(groups []*GroupInfo, minConstraint, maxConstraint, target }) } - if len(groups) < minConstraint { - return - } - - if len(groups) == minConstraint { - var sum int - rootPath := new(dfsPath) - for _, i := range groups { - sum += i.value - rootPath.enqueue(i) - } - if sum >= target { - paths = append(paths, rootPath.next()) - } - return - } - rootPath := new(dfsPath) var dfsFunc func(int, int) dfsFunc = func(sum, begin int) { + // directly check the sum + if len(groups) == minConstraint { + for _, group := range groups { + sum += group.value + rootPath.enqueue(group) + } + if sum >= target { + paths = append(paths, rootPath.next()) + } + return + } + if sum >= target && rootPath.length() >= minConstraint && rootPath.length() <= maxConstraint { paths = append(paths, rootPath.next()) return