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