Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/workflow/checkout_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ func mergeSparsePatterns(existing []string, newPatterns string) []string {
// mergeFetchRefs unions two sets of fetch ref patterns preserving insertion order.
func mergeFetchRefs(existing []string, newRefs []string) []string {
seen := make(map[string]bool, len(existing))
result := make([]string, 0, len(existing)+len(newRefs))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot do not pre-allocate size

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 6c2f7df — replaced make([]string, 0, capacity) with make([]string, 0) and removed the math import.

result := make([]string, 0)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping pre-allocation entirely fixes the overflow, but it also guarantees extra realloc/copy work for typical inputs. You can keep the fix and still reduce allocations by preallocating to len(existing) (safe since it doesn’t involve an addition) or by using an overflow-checked sum before setting capacity.

Suggested change
result := make([]string, 0)
result := make([]string, 0, len(existing))

Copilot uses AI. Check for mistakes.
for _, r := range existing {
r = strings.TrimSpace(r)
if r != "" && !seen[r] {
Expand Down
Loading