Skip to content

Commit

Permalink
perf(conv): Reduce allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
kanru committed May 9, 2024
1 parent 453f9a9 commit 0c44281
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/conversion/chewing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,13 @@ impl ChewingEngine {
return Some(symbols[0].into());
}

let syllables = symbols
.iter()
.take_while(|symbol| symbol.is_syllable())
.map(|symbol| symbol.to_syllable().unwrap())
.collect::<Vec<_>>();
if syllables.len() != symbols.len() {
if symbols.iter().any(|sym| sym.is_char()) {
return None;
}

let mut max_freq = 0;
let mut best_phrase = None;
'next_phrase: for phrase in dict.lookup_all_phrases(&syllables) {
'next_phrase: for phrase in dict.lookup_all_phrases(&symbols) {
// If there exists a user selected interval which is a
// sub-interval of this phrase but the substring is
// different then we can skip this phrase.
Expand Down

0 comments on commit 0c44281

Please sign in to comment.