diff --git a/pkg/promotions/eval.go b/pkg/promotions/eval.go index c30addc..aebb66a 100644 --- a/pkg/promotions/eval.go +++ b/pkg/promotions/eval.go @@ -3,6 +3,7 @@ package promotions import ( "errors" "fmt" + "slices" "strings" "time" @@ -346,10 +347,8 @@ func evaluateBaseCondition(b BaseCondition, ctx *PromotionEvalContext) bool { } func evalAnyItemMatch(pred func(PromotionItem) bool, b BaseCondition, ctx *PromotionEvalContext) bool { - for _, it := range ctx.Items { - if pred(it) { - return true - } + if slices.ContainsFunc(ctx.Items, pred) { + return true } switch normalizeOperator(string(b.Operator)) { case string(OpNotIn), string(OpNotContains): @@ -704,12 +703,7 @@ func normalizeLogicOperator(op string) string { } func sliceFloatContains(list []float64, v float64) bool { - for _, x := range list { - if x == v { - return true - } - } - return false + return slices.Contains(list, v) } // ----------------------------