Skip to content

🌱 refactor: replace slower and inefficient sorting functions #12473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Surya-7890
Copy link
Contributor

@Surya-7890 Surya-7890 commented Jul 10, 2025

This PR replaces all the instances of

  • sort.Sort with slices.SortFunc
  • sort.Slice with slices.SortFunc
  • sort.SliceStable with slices.SortStableFunc

The godocs for the existing sorting functions recommend using the alternatives provides, as they are faster and more efficient.

What this PR does / why we need it:
Currently, slower sorting functions are being used, these must be replaced with faster and more efficient sorting functions.

Which issue(s) this PR fixes:
Fixes #12426

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 10, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/needs-area PR is missing an area label label Jul 10, 2025
@k8s-ci-robot
Copy link
Contributor

This PR is currently missing an area label, which is used to identify the modified component when generating release notes.

Area labels can be added by org members by writing /area ${COMPONENT} in a comment

Please see the labels list for possible areas.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 10, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign joelspeed for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Hi @Surya-7890. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 10, 2025
@Surya-7890 Surya-7890 changed the title 🌱 refactor: replace sort.Sort with slices.SortFunc 🌱 refactor: replace slower and inefficient sorting functions Jul 10, 2025
@sbueringer
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 10, 2025
@Surya-7890 Surya-7890 force-pushed the refactor/replace-slower-sorting-functions branch from c3aafa6 to 5b73737 Compare July 10, 2025 15:12
@Surya-7890
Copy link
Contributor Author

/retest

@Surya-7890
Copy link
Contributor Author

/retest-required

@Surya-7890 Surya-7890 force-pushed the refactor/replace-slower-sorting-functions branch from 516df73 to f543ab8 Compare July 11, 2025 04:31
@Surya-7890
Copy link
Contributor Author

/retest-required

This commit replaces all the instances of sort.Sort with slices.SortFunc.
The godocs for sort.Sort recommends using slices.SortFunc, as it is faster and more efficient.
@Surya-7890 Surya-7890 force-pushed the refactor/replace-slower-sorting-functions branch from f543ab8 to 66d3377 Compare July 11, 2025 05:01
@Surya-7890
Copy link
Contributor Author

/retest-required

This commit replaces all the instances of sort.Slice with slices.SortFunc.
The godocs for sort.Slice recommends using slices.SortFunc, as it is faster and more efficient.
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 11, 2025
@Surya-7890
Copy link
Contributor Author

/retest-required

This commit replaces all the instances of sort.SliceStable with slices.SortStableFunc.
The godocs for sort.SliceStable recommends using slices.SortStableFunc, as it is faster and more efficient.
@Surya-7890
Copy link
Contributor Author

/retest-required

@Surya-7890 Surya-7890 marked this pull request as ready for review July 11, 2025 09:28
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 11, 2025
@k8s-ci-robot k8s-ci-robot requested review from chrischdi and elmiko July 11, 2025 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area PR is missing an area label ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use slices.SortFunc instead of other sorting funcs
3 participants