Skip to content

perf: Refactored sorting to use optimized sort algorithms#2161

Open
dhoard wants to merge 2 commits into
prometheus:mainfrom
dhoard:perf/refacatored-sort-algorithm
Open

perf: Refactored sorting to use optimized sort algorithms#2161
dhoard wants to merge 2 commits into
prometheus:mainfrom
dhoard:perf/refacatored-sort-algorithm

Conversation

@dhoard
Copy link
Copy Markdown
Collaborator

@dhoard dhoard commented May 29, 2026

Refactored code to use optimized sort algorithms.

Signed-off-by: dhoard <doug.hoard@gmail.com>
@dhoard dhoard changed the title perf: Refactoring sorting to use optimized sort algorithms perf: Refactored sorting to use optimized sort algorithms May 29, 2026
@dhoard dhoard removed the request for review from fstab May 29, 2026 01:35
Copy link
Copy Markdown
Member

@zeitlinger zeitlinger left a comment

Choose a reason for hiding this comment

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

Great - only wonder if this could be re-usable. Either generics or generating code code.

* <p>Uses 3-way quicksort partitioning for large ranges, insertion sort for tiny ranges, and a
* heapsort fallback at the recursion-depth limit to guarantee O(n log n) worst-case complexity.
*/
private static final class StringArraySorter {
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 pretty similar to last sorter - can we use generics or would this break perf?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Most likely. I chose to keep the code isolated like the Bubble sort implementation.

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.

2 participants