From 8969c02581f9bf4f1200562d75acd4d238848708 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 19 Apr 2026 12:08:03 +0800 Subject: [PATCH] refactor: avoid map allocation in positiveLabelsCompatibleWith Compare positive label slices directly instead of allocating a map per comparison, as label counts are typically small (1-3 entries). Addresses Copilot review comment on PR #2545. Signed-off-by: yxxhero --- pkg/state/release_filters.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pkg/state/release_filters.go b/pkg/state/release_filters.go index 9247f3fa..dfc482e7 100644 --- a/pkg/state/release_filters.go +++ b/pkg/state/release_filters.go @@ -95,13 +95,11 @@ func parseLabelFilters(selectors []string) ([]LabelFilter, error) { // positiveLabelsCompatibleWith returns true if the positive labels of two filters // do not conflict (i.e., no shared key with a different value). func (l LabelFilter) positiveLabelsCompatibleWith(other LabelFilter) bool { - otherPos := make(map[string]string, len(other.positiveLabels)) - for _, kv := range other.positiveLabels { - otherPos[kv[0]] = kv[1] - } - for _, kv := range l.positiveLabels { - if v, ok := otherPos[kv[0]]; ok && v != kv[1] { - return false + for _, a := range l.positiveLabels { + for _, b := range other.positiveLabels { + if a[0] == b[0] && a[1] != b[1] { + return false + } } } return true