Skip to content

Conversation

@belugabehr
Copy link

Removes the isSortedSet() pre-check before calling Arrays.sort() in both KeyValues and Tags classes. Modern JVM implementations make this optimization unnecessary and potentially counterproductive

Arrays.sort() uses TimSort which is already optimized for sorted arrays with O(n) best-case complexity. The pre-sort check adds unnecessary overhead for unsorted data (common case) without significant benefit.

  • Simplified toKeyValues() and toTags() by removing isSortedSet() method and relying on TimSort's adaptive sorting behavior.
  • The isSortedSet(array, length) method was only ever called with length = array.length. The check if (length > array.length) could never be true, making this guard condition pointless.

Arrays.sort() uses TimSort which is already optimized for sorted arrays
with O(n) best-case complexity. The pre-sort check adds unnecessary
overhead for unsorted data (common case) without significant benefit.

Simplified toKeyValues() and toTags() by removing isSortedSet() method
and relying on TimSort's adaptive sorting behavior.

Signed-off-by: David Mollitor <[email protected]>
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.

1 participant