Skip to content

Optimize: Use maps.Keys, slices.Collect and slices.Contains instead of custom functions#3758

Merged
ndyakov merged 2 commits into
redis:masterfrom
cxljs:modern-go-optimizations
Mar 30, 2026
Merged

Optimize: Use maps.Keys, slices.Collect and slices.Contains instead of custom functions#3758
ndyakov merged 2 commits into
redis:masterfrom
cxljs:modern-go-optimizations

Conversation

@cxljs

@cxljs cxljs commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Note

Medium Risk
Mostly mechanical refactors, but it changes core PubSub/Sentinel code paths and relies on newer stdlib helpers (maps.Keys + slices.Collect/slices.Contains), which could break builds if the project’s Go version isn’t aligned.

Overview
Removes custom slice/map helper functions and replaces them with standard library utilities.

In pubsub.go, channel/pattern key collection for PubSub.String(), connection setup, and resubscription now uses slices.Collect(maps.Keys(...)) instead of a local mapKeys helper. In sentinel.go, sentinel address deduplication switches from a local contains helper to slices.Contains.

Doctest examples in doctests/timeseries_tut_test.go similarly migrate map key collection to slices.Collect(maps.Keys(...)) and drop the tutorial-local mapKeys implementation.

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

…slices.Contains) instead of custom functions
@cxljs cxljs requested a review from dmaier-redislabs as a code owner March 30, 2026 14:06
@cxljs

cxljs commented Mar 30, 2026

Copy link
Copy Markdown
Contributor Author

My apologies, these changes should have been included in PR #3746 , but I missed them.

@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.

looks good, @cxljs!

@ndyakov ndyakov merged commit 3732440 into redis:master Mar 30, 2026
56 of 57 checks passed
romanpovol pushed a commit to romanpovol/go-redis that referenced this pull request Apr 8, 2026
…instead of custom functions (redis#3758)

* Optimize: Use modern Go standard library (maps.Keys, slices.Collect, slices.Contains) instead of custom functions

* format
ndyakov added a commit that referenced this pull request Apr 9, 2026
* feat(vectorset): WIP

* feat(vectorsets): WITHATTRIBS & VIsMember

* fix(vectorsets): fix tests

* fix(vectorsets): improve doctest/

* feat(vectorsets): add test with nil attrs

* fix(vectorsets): typo Epsilon

* fix: review issues

* chore(go): use -compat=1.24 (#3754)

Signed-off-by: Xiaolong Chen <fukua95@gmail.com>

* chore(maps): Use `maps.Keys`, `slices.Collect` and `slices.Contains` instead of custom functions (#3758)

* Optimize: Use modern Go standard library (maps.Keys, slices.Collect, slices.Contains) instead of custom functions

* format

* chore(deps): bump codecov/codecov-action from 5 to 6 (#3757)

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5 to 6.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v5...v6)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(ring): inline rendezvous hashing and remove external dependency (#3762)

* ring: remove external rendezvous dependency by inlining implementation

Replace usage of github.com/dgryski/go-rendezvous with an internal
implementation to eliminate the external dependency and avoid licence
propagation concerns.

The implementation preserves the exact hashing algorithm and behaviour:
- same hash combination: khash ^ nhash
- same mixing function (xorshift* variant)
- same node ordering semantics

No functional changes intended.

* Refactor TestRendezvous to remove randomString function

Replaced function with inline string generation for test cases.

* test: refactor RendezvousHash tests to use Ginkgo and Gomega

* test: improve RendezvousHash test for per-instance determinism and distribution balance

* test: enhance distribution verification in RendezvousHash tests

---------

Signed-off-by: Xiaolong Chen <fukua95@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: cxljs <fukua95@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bigsk <i@ianxia.com>
Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
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