From 83e1d69a376d2a52869a074a043dc026483b73d9 Mon Sep 17 00:00:00 2001 From: Riceball LEE Date: Tue, 21 Jan 2025 20:26:08 +0800 Subject: [PATCH] refactor: remove unused `longest_word_len` --- src/lib.rs | 13 ------------- tests/test_wasm.rs | 2 ++ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 69cd8a9..d6fe0b3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -223,7 +223,6 @@ pub struct Jieba { records: Vec, cedar: Cedar, total: usize, - longest_word_len: usize, } #[cfg(feature = "default-dict")] @@ -240,7 +239,6 @@ impl Jieba { records: Vec::new(), cedar: Cedar::new(), total: 0, - longest_word_len: 0, } } @@ -289,11 +287,6 @@ 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 } @@ -301,7 +294,6 @@ impl Jieba { pub fn load_dict(&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 { @@ -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; diff --git a/tests/test_wasm.rs b/tests/test_wasm.rs index bf8f70c..29a5426 100644 --- a/tests/test_wasm.rs +++ b/tests/test_wasm.rs @@ -1,3 +1,5 @@ +#![cfg(target_arch = "wasm32")] + use jieba_rs::Jieba; use wasm_bindgen_test::*;