Skip to content

chore: replace sort.Slice with slices.SortFunc - #4034

Open
aheritier wants to merge 1 commit into
mainfrom
feat/slices-sortfunc
Open

chore: replace sort.Slice with slices.SortFunc#4034
aheritier wants to merge 1 commit into
mainfrom
feat/slices-sortfunc

Conversation

@aheritier

Copy link
Copy Markdown
Collaborator

Replace 7 sort.Slice/sort.SliceStable calls with slices.SortFunc/slices.SortStableFunc + cmp.Compare across 4 files.

Why: slices.SortFunc avoids reflection, is type-safe, and is the idiomatic API since Go 1.21 (no dependency on the Go 1.27 upgrade).

Files changed:

  • pkg/tools/builtin/plan/plan.go — 1 call
  • pkg/tools/builtin/mcpcatalog/mcpcatalog.go — 3 calls
  • pkg/sandbox/kit/kit.go — 2 calls
  • pkg/plans/service.go — 1 call (stable sort preserved via SortStableFunc)

Testing: go build ./..., go test on all 4 touched packages, go vet, go run ./lint ., go mod tidy --diff all pass clean.

Replace 7 sort.Slice/sort.SliceStable calls with slices.SortFunc/
slices.SortStableFunc + cmp.Compare across 4 files. The slices package
is more efficient (no reflection), type-safe, and idiomatic Go.

The sort.Strings call sites are unchanged; "sort" is retained in files
that still use it.
@aheritier
aheritier marked this pull request as ready for review August 22, 2026 16:02
@aheritier
aheritier requested a review from a team as a code owner August 22, 2026 16:02
@aheritier aheritier added area/tools For features/issues/fixes related to the usage of built-in and MCP tools kind/chore Maintenance, deps, CI, tooling (maps to chore: commit prefix) labels Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tools For features/issues/fixes related to the usage of built-in and MCP tools kind/chore Maintenance, deps, CI, tooling (maps to chore: commit prefix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant