mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-08 01:52:54 +00:00
use while let instead of loop and if.
as per CR comment
This commit is contained in:
@@ -112,26 +112,20 @@ fn search_fragments<'a>(
|
||||
let mut fragment = FragmentCandidate::new(0, 0);
|
||||
let mut fragments:Vec<FragmentCandidate> = vec![];
|
||||
|
||||
loop {
|
||||
if let Some(next) = token_stream.next() {
|
||||
if (next.offset_to - fragment.start_offset) > max_num_chars {
|
||||
let txt = &text[fragment.start_offset..fragment.stop_offset];
|
||||
if fragment.score > 0.0 {
|
||||
fragments.push(fragment)
|
||||
};
|
||||
fragment = FragmentCandidate::new(next.offset_from, next.offset_to);
|
||||
} else {
|
||||
fragment.calculate_score(next, &terms);
|
||||
fragment.stop_offset = next.offset_to;
|
||||
}
|
||||
} else {
|
||||
let txt = &text[fragment.start_offset..fragment.stop_offset];
|
||||
while let Some(next) = token_stream.next() {
|
||||
if (next.offset_to - fragment.start_offset) > max_num_chars {
|
||||
if fragment.score > 0.0 {
|
||||
fragments.push(fragment)
|
||||
};
|
||||
break;
|
||||
fragment = FragmentCandidate::new(next.offset_from, next.offset_to);
|
||||
} else {
|
||||
fragment.calculate_score(next, &terms);
|
||||
fragment.stop_offset = next.offset_to;
|
||||
}
|
||||
}
|
||||
if fragment.score > 0.0 {
|
||||
fragments.push(fragment)
|
||||
}
|
||||
|
||||
fragments
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user