Skip to content

Commit

Permalink
move debug_assert
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz authored Sep 4, 2024
1 parent 5335c67 commit a67f7ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/snippet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ fn sort_and_deduplicate_ranges(ranges: &[Range<usize>]) -> Vec<Range<usize>> {
/// - [0..2, 1..3] -> [0..3] # overlapping, merged
/// - [0..3, 1..2] -> [0..3] # second range is completely within the first
fn merge_overlapping_ranges(ranges: &[Range<usize>]) -> Vec<Range<usize>> {
debug_assert!(is_sorted(ranges.iter().map(|range| range.start)));
let mut result = Vec::<Range<usize>>::new();
for range in ranges {
if let Some(last) = result.last_mut() {
Expand Down Expand Up @@ -315,7 +316,6 @@ fn merge_overlapping_ranges(ranges: &[Range<usize>]) -> Vec<Range<usize>> {
/// - [0..3, 3..6, 0..3, 3..6] -> [0..6] # duplicates removed, then merged
pub fn collapse_overlapped_ranges(ranges: &[Range<usize>]) -> Vec<Range<usize>> {
let prepared = sort_and_deduplicate_ranges(ranges);
debug_assert!(is_sorted(prepared.iter().map(|range| range.start)));
merge_overlapping_ranges(&prepared)
}

Expand Down

0 comments on commit a67f7ab

Please sign in to comment.