Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
makotokato committed Aug 17, 2021
1 parent 251583d commit 4d79bbc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/bytestrie.rs → src/bytes_trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl BytesTrie {
trie_data: &[u8],
pos: usize,
length: usize,
in_unit: u8,
in_byte: u8,
) -> TrieResult {
let mut pos = pos;
let mut length = length;
Expand All @@ -139,7 +139,7 @@ impl BytesTrie {
// The length of the branch is the number of units to select from.
// The data structure encodes a binary search.
while length > MAX_BRANCH_LINEAR_SUB_NODE_LENGTH {
if in_unit < trie_data[pos] {
if in_byte < trie_data[pos] {
length >>= 1;
pos = self.jump_by_delta(trie_data, pos + 1);
} else {
Expand All @@ -151,7 +151,7 @@ impl BytesTrie {
// length>=2 because the loop body above sees length>kMaxBranchLinearSubNodeLength>=3
// and divides length by 2.
loop {
if in_unit == trie_data[pos] {
if in_byte == trie_data[pos] {
pos += 1;
let mut node = trie_data[pos];
assert!(node >= MIN_VALUE_LEAD);
Expand Down Expand Up @@ -202,7 +202,7 @@ impl BytesTrie {
}
}

if in_unit == trie_data[pos] {
if in_byte == trie_data[pos] {
pos += 1;
self.pos_ = Some(pos);
let node = trie_data[pos];
Expand All @@ -216,17 +216,17 @@ impl BytesTrie {
}
}

fn next_impl(&mut self, trie_data: &[u8], pos: usize, in_unit: u8) -> TrieResult {
fn next_impl(&mut self, trie_data: &[u8], pos: usize, in_byte: u8) -> TrieResult {
let mut pos = pos;
loop {
let mut node = trie_data[pos];
pos += 1;
if node < MIN_LINEAR_MATCH {
return self.branch_next(trie_data, pos, node as usize, in_unit);
return self.branch_next(trie_data, pos, node as usize, in_byte);
} else if node < MIN_VALUE_LEAD {
// Match the first of length+1 units.
let length = node - MIN_LINEAR_MATCH;
if in_unit == trie_data[pos] {
if in_byte == trie_data[pos] {
pos += 1;
if length == 0 {
self.remaining_match_length_ = None;
Expand Down
6 changes: 3 additions & 3 deletions src/dictionary_iter.rs → src/dictionary_iterator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::bytestrie::*;
use crate::bytes_trie::*;
use crate::trie::*;
use crate::ucharstrie::*;
use crate::uchars_trie::*;

const TRIE_TYPE_BYTES: u32 = 0;
const TRIE_TYPE_UCHARS: u32 = 1;
Expand Down Expand Up @@ -129,7 +129,7 @@ impl<'a> DictionaryIterator<'a> {

#[cfg(test)]
mod tests {
use crate::dictionary_iter::*;
use crate::dictionary_iterator::*;
const KHMER_DATA: &[u8; 445542] = include_bytes!("../data/khmerdict.dict");
const LAO_DATA: &[u8; 162620] = include_bytes!("../data/laodict.dict");
const CJ_DATA: &[u8; 2003566] = include_bytes!("../data/cjdict.dict");
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod bytestrie;
mod dictionary_iter;
mod bytes_trie;
mod dictionary_iterator;
mod trie;
mod ucharstrie;
mod uchars_trie;

pub use crate::dictionary_iter::DictionaryIterator;
pub use crate::dictionary_iterator::DictionaryIterator;
File renamed without changes.

0 comments on commit 4d79bbc

Please sign in to comment.