Skip to content

Conversation

@gzliudan
Copy link
Collaborator

@gzliudan gzliudan commented Jan 9, 2026

Proposed changes

Use modern go language to improve function BuildConfigIndex

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

Copilot AI review requested due to automatic review settings January 9, 2026 03:19
@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the BuildConfigIndex() function in the params package by replacing a manual O(n²) bubble sort implementation with modern Go standard library functions. The refactoring improves code readability and performance while maintaining the same functionality.

Key Changes:

  • Replaced manual loop and bubble sort with slices.Collect(maps.Keys()) and slices.SortFunc()
  • Added comprehensive test case to verify descending order sorting behavior
  • Reduced code complexity from ~10 lines to ~3 lines

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
params/config.go Refactored BuildConfigIndex() to use modern Go standard library functions (maps.Keys, slices.Collect, slices.SortFunc) for improved performance and readability
params/config_test.go Added new test TestBuildConfigIndexDescendingOrder to verify the descending order sorting behavior with a clean, isolated test case

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gzliudan gzliudan force-pushed the build-config-index branch 2 times, most recently from c166004 to 85bc0b3 Compare January 9, 2026 03:46
@gzliudan gzliudan changed the title params: improve func BuildConfigIndex() params: improve func BuildConfigIndex() Jan 9, 2026
@gzliudan gzliudan force-pushed the build-config-index branch from 85bc0b3 to be8f0b0 Compare January 9, 2026 03:51
@gzliudan gzliudan force-pushed the build-config-index branch from be8f0b0 to b494116 Compare January 9, 2026 04:05
@AnilChinchawale AnilChinchawale merged commit 7267895 into XinFinOrg:dev-upgrade Jan 16, 2026
13 checks passed
@gzliudan gzliudan deleted the build-config-index branch January 16, 2026 10:25
@gzliudan gzliudan mentioned this pull request Jan 16, 2026
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants