Skip to content

Optimize for Go 1.24: use slices/maps/clear built-ins #3746

Merged
ndyakov merged 1 commit into
redis:masterfrom
cxljs:optimize-go124
Mar 23, 2026
Merged

Optimize for Go 1.24: use slices/maps/clear built-ins #3746
ndyakov merged 1 commit into
redis:masterfrom
cxljs:optimize-go124

Conversation

@cxljs

@cxljs cxljs commented Mar 22, 2026

Copy link
Copy Markdown
Contributor
  • pubsub.go: use clear() to empty maps
  • search_commands.go: use slices.Clone() and maps.Clone()
  • command.go: use maps.Clone() in XMessageSliceCmd.Clone()
  • options.go: use maps.Keys() + slices.Collect() + slices.Sort()
  • osscluster.go: use slices.SortFunc() instead of custom sort type
  • proxy_fault_injector_server.go: remove custom min() function

Note

Low Risk
Low risk refactor that swaps hand-written clone/sort/map-clear logic for Go stdlib/built-ins; behavior should remain the same but could surface subtle ordering/copy semantics issues in edge cases.

Overview
Modernizes several internals to use Go 1.21+ helpers: maps.Clone/slices.Clone for command result cloning (streams/search), clear() for PubSub unsubscribe state, and maps.Keys+slices.Sort / slices.SortFunc (with cmp.Compare) for deterministic option parsing and cluster slot ordering.

Also removes a local min() helper in the e2e proxy fault injector in favor of the built-in min.

Written by Cursor Bugbot for commit e4de127. This will update automatically on new commits. Configure here.

@jit-ci

jit-ci Bot commented Mar 22, 2026

Copy link
Copy Markdown

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Comment thread osscluster.go

@ndyakov ndyakov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @cxljs !

- pubsub.go: use clear() to empty maps
- search_commands.go: use slices.Clone() and maps.Clone()
- command.go: use maps.Clone() in XMessageSliceCmd.Clone()
- options.go: use maps.Keys() + slices.Collect() + slices.Sort()
- osscluster.go: use slices.SortFunc() instead of custom sort type
- proxy_fault_injector_server.go: remove custom min() function
@ndyakov ndyakov merged commit 0ae2f4c into redis:master Mar 23, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants