Skip to content

Conversation

@SyMind
Copy link
Member

@SyMind SyMind commented Oct 31, 2025

This PR refactors the ReplaceSource replacement ordering logic to make it order-independent. The PR removes the Ord and PartialOrd trait implementations from the Replacement struct and replaces them with a custom comparison function and an optimized binary search algorithm.

  • Custom comparison function (compare_replacement_order) replaces trait-based ordering
  • Custom binary search implementation (find_insert_index) for better performance with predictable branch patterns
  • Manual trait implementations for Hash, PartialEq, and Eq that exclude insertion_order to ensure deterministic hashing
  • New test verifying order-independence of replacements
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 31, 2025

CodSpeed Performance Report

Merging #195 will not alter performance

Comparing fix-replacement (4d1a46c) with main (c4f7e16)

Summary

✅ 11 untouched
⏩ 5 skipped1

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@SyMind SyMind marked this pull request as ready for review October 31, 2025 03:12
Copilot AI review requested due to automatic review settings October 31, 2025 03:12
@SyMind SyMind changed the title fix: replace source is order independent fix: replace source should be order independent Oct 31, 2025
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 refactors the ReplaceSource replacement ordering logic to make it order-independent. The PR removes the Ord and PartialOrd trait implementations from the Replacement struct and replaces them with a custom comparison function and an optimized binary search algorithm.

  • Custom comparison function (compare_replacement_order) replaces trait-based ordering
  • Custom binary search implementation (find_insert_index) for better performance with predictable branch patterns
  • Manual trait implementations for Hash, PartialEq, and Eq that exclude insertion_order to ensure deterministic hashing
  • New test verifying order-independence of replacements

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/source.rs Adds PartialEq and Eq derives to SourceValue enum
src/replace_source.rs Refactors replacement ordering logic, removes Ord/PartialOrd traits, adds custom binary search, manual trait implementations, and new test for order-independence
Cargo.toml Adds rand = "0.9.2" as dev-dependency for testing
Cargo.lock Updates lock file with rand 0.9.2 and its dependencies

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

@SyMind SyMind changed the title fix: replace source should be order independent fix: replace source hash should be order independent Oct 31, 2025
@SyMind SyMind merged commit d32c0cc into main Oct 31, 2025
10 checks passed
@SyMind SyMind deleted the fix-replacement branch October 31, 2025 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants