Added inline to most functions
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
[workspace]
|
||||
members = ["crates/*"]
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
||||
@@ -11,7 +11,6 @@ name = "bench"
|
||||
harness = false
|
||||
|
||||
[dependencies]
|
||||
# fst = "0.4.7"
|
||||
tinyvec = { version = "1.6.0", features = ["alloc"] }
|
||||
u-fst = { path = "../u-fst" }
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ pub struct Decompositions<I> {
|
||||
impl<I: Iterator<Item = char>> Iterator for Decompositions<I> {
|
||||
type Item = char;
|
||||
|
||||
#[inline(always)]
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
while self.buffer.ready.end == 0 {
|
||||
match self.iter.next() {
|
||||
@@ -125,6 +126,7 @@ const T_COUNT: u32 = 28;
|
||||
const N_COUNT: u32 = V_COUNT * T_COUNT;
|
||||
const S_COUNT: u32 = L_COUNT * N_COUNT;
|
||||
|
||||
#[inline(always)]
|
||||
fn decompose(c: char, buffer: &mut Buffer) {
|
||||
// 7-bit ASCII never decomposes
|
||||
if c <= '\x7f' {
|
||||
@@ -155,10 +157,12 @@ fn decompose(c: char, buffer: &mut Buffer) {
|
||||
buffer.push_back(c);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn is_hangul_syllable(c: char) -> bool {
|
||||
(c as u32) >= S_BASE && (c as u32) < (S_BASE + S_COUNT)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[allow(unsafe_code)]
|
||||
fn decompose_hangul(s: char, buffer: &mut Buffer) {
|
||||
let s_index = s as u32 - S_BASE;
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
use u_norm::table;
|
||||
use std::fs;
|
||||
|
||||
fn main() {
|
||||
for c in '\x00'..='\x7f' {
|
||||
let d = table::lookup(c);
|
||||
let long = fs::read_to_string("benches/long.txt").unwrap();
|
||||
|
||||
println!(
|
||||
"{:?} class: {}, decomp: {:?}",
|
||||
c,
|
||||
d.combining_class(),
|
||||
d.decomposition().map(|d| d.collect::<Vec<_>>())
|
||||
);
|
||||
println!("{}", u_norm::nfd(&long).count());
|
||||
|
||||
/*
|
||||
for ch in u_norm::nfd(&long) {
|
||||
print!("{} ", u_norm::table::lookup(ch).combining_class());
|
||||
}
|
||||
|
||||
println!();
|
||||
*/
|
||||
|
||||
/*
|
||||
let mut count = 0;
|
||||
|
||||
for _ in 0..5000 {
|
||||
count += u_norm::nfd(&long).count();
|
||||
}
|
||||
|
||||
println!("count: {}", count / 5000);
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user