Skip to content

Commit

Permalink
remove unneeded flag in regex matches
Browse files Browse the repository at this point in the history
  • Loading branch information
benbrandt committed Dec 27, 2023
1 parent 294c1bd commit 4b0effc
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ where
.map(|(i, str)| (self.cursor + i, str)),
SemanticLevel::LineBreak(_) => split_str_by_separator(
text,
true,
self.line_breaks
.ranges(self.cursor, semantic_level)
.map(|(_, sep)| sep.start - self.cursor..sep.end - self.cursor),
Expand Down Expand Up @@ -753,7 +752,6 @@ where
/// Given a list of separator ranges, construct the sections of the text
fn split_str_by_separator(
text: &str,
separator_is_own_chunk: bool,
separator_ranges: impl Iterator<Item = Range<usize>>,
) -> impl Iterator<Item = (usize, &str)> {
let mut cursor = 0;
Expand All @@ -768,7 +766,7 @@ fn split_str_by_separator(
text.get(cursor..).map(|t| Either::Left(once((cursor, t))))
}
// Return text preceding match + the match
Some(range) if separator_is_own_chunk => {
Some(range) => {
let offset = cursor;
let prev_section = text
.get(cursor..range.start)
Expand All @@ -781,16 +779,6 @@ fn split_str_by_separator(
[(offset, prev_section), (range.start, separator)].into_iter(),
))
}
// Return just the text preceding the match
Some(range) => {
let offset = cursor;
let prev_section = text
.get(cursor..range.start)
.expect("invalid character sequence");
// Separator will be part of the next chunk
cursor = range.start;
Some(Either::Left(once((offset, prev_section))))
}
})
.flatten()
}
Expand Down

0 comments on commit 4b0effc

Please sign in to comment.