Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolas Polomack <[email protected]>
  • Loading branch information
Dalvany and Hirevo committed Jun 27, 2023
1 parent 1e7f80e commit 14ff5a9
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions crates/alexandrie/src/fts/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,18 +395,30 @@ impl Tantivy {
let mut doc: TantivyDocument = krate.into();

// Skip keywords that might be orphan and add keywords that match ids
while current_keyword.is_some() && current_keyword.as_ref().unwrap().0 <= id {
if current_keyword.as_ref().unwrap().0 == id {
doc.add_keyword(current_keyword.unwrap().1);
while let Some((crate_id, keyword)) = current_keyword {
if crate_id > id {
current_keyword = Some((crate_id, keyword));
break;
}

if crate_id == id {
doc.add_keyword(keyword);
}

current_keyword = keywords_iterator.next();
}

// Skip keywords that might be orphan and add keywords that match ids
while current_category.is_some() && current_category.as_ref().unwrap().0 <= id {
if current_category.as_ref().unwrap().0 == id {
doc.add_keyword(current_category.unwrap().1);
// Skip categories that might be orphan and add categories that match ids
while let Some((crate_id, category)) = current_category {
if crate_id > id {
current_category = Some((crate_id, category));
break;
}

if crate_id == id {
doc.add_category(category);
}

current_category = categories_iterator.next();
}

Expand Down

0 comments on commit 14ff5a9

Please sign in to comment.