Skip to content

Commit

Permalink
refactor: remove unused longest_word_len
Browse files Browse the repository at this point in the history
  • Loading branch information
snowyu authored and messense committed Jan 21, 2025
1 parent c609223 commit 83e1d69
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ pub struct Jieba {
records: Vec<Record>,
cedar: Cedar,
total: usize,
longest_word_len: usize,
}

#[cfg(feature = "default-dict")]
Expand All @@ -240,7 +239,6 @@ impl Jieba {
records: Vec::new(),
cedar: Cedar::new(),
total: 0,
longest_word_len: 0,
}
}

Expand Down Expand Up @@ -289,19 +287,13 @@ impl Jieba {
}
};

let curr_word_len = word.chars().count();
if self.longest_word_len < curr_word_len {
self.longest_word_len = curr_word_len;
}

freq
}

/// Load dictionary
pub fn load_dict<R: BufRead>(&mut self, dict: &mut R) -> Result<(), Error> {
let mut buf = String::new();
self.total = 0;
self.longest_word_len = 0;

let mut line_no = 0;
while dict.read_line(&mut buf)? > 0 {
Expand All @@ -322,11 +314,6 @@ impl Jieba {
.unwrap_or(Ok(0))?;
let tag = iter.next().unwrap_or("");

let curr_word_len = word.chars().count();
if self.longest_word_len < curr_word_len {
self.longest_word_len = curr_word_len;
}

match self.cedar.exact_match_search(word) {
Some((word_id, _, _)) => {
self.records[word_id as usize].freq = freq;
Expand Down
2 changes: 2 additions & 0 deletions tests/test_wasm.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(target_arch = "wasm32")]

use jieba_rs::Jieba;
use wasm_bindgen_test::*;

Expand Down

0 comments on commit 83e1d69

Please sign in to comment.