Skip to content

Commit

Permalink
minor fix: use if-else instead of match statement
Browse files Browse the repository at this point in the history
Signed-off-by: xiarui.xr <[email protected]>
  • Loading branch information
amyXia1994 committed Oct 12, 2023
1 parent 892d519 commit f07ea31
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions kclvm/tools/src/LSP/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,25 +817,22 @@ fn line_to_words(text: String) -> HashMap<String, Vec<Word>> {
if is_id_start && !prev_word {
start_pos = i;
}
match is_id_continue {
true => {
// Continue searching for the end position.
if start_pos != usize::MAX {
continue_pos = i;
}
if is_id_continue {
// Continue searching for the end position.
if start_pos != usize::MAX {
continue_pos = i;
}
false => {
// Find out the end position.
if continue_pos + 1 == i {
words.push(Word::new(
start_pos as u32,
i as u32,
chars[start_pos..i].iter().collect::<String>().clone(),
));
}
// Reset the start position.
start_pos = usize::MAX;
} else {
// Find out the end position.
if continue_pos + 1 == i {
words.push(Word::new(
start_pos as u32,
i as u32,
chars[start_pos..i].iter().collect::<String>().clone(),
));
}
// Reset the start position.
start_pos = usize::MAX;
}
prev_word = is_id_continue;
}
Expand Down

0 comments on commit f07ea31

Please sign in to comment.