diff --git a/Cargo.toml b/Cargo.toml index 60532fe..ab5cb0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,5 +20,6 @@ Unicode Standard Annex #15. exclude = [ "target/*", "Cargo.lock", "scripts/tmp", "*.txt", "tests/*" ] -[dependencies] -smallvec = "1.1" +[dependencies.tinyvec] +version = "0.3.2" +features = ["alloc"] diff --git a/src/decompose.rs b/src/decompose.rs index b4ef386..6533c0c 100644 --- a/src/decompose.rs +++ b/src/decompose.rs @@ -7,7 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -use smallvec::SmallVec; +use tinyvec::TinyVec; use std::fmt::{self, Write}; use std::iter::Fuse; use std::ops::Range; @@ -32,7 +32,7 @@ pub struct Decompositions { // 2) "Ready" characters which are sorted and ready to emit on demand; // 3) A "pending" block which stills needs more characters for us to be able // to sort in canonical order and is not safe to emit. - buffer: SmallVec<[(u8, char); 4]>, + buffer: TinyVec<[(u8, char); 4]>, ready: Range, } @@ -41,7 +41,7 @@ pub fn new_canonical>(iter: I) -> Decompositions { Decompositions { kind: self::DecompositionType::Canonical, iter: iter.fuse(), - buffer: SmallVec::new(), + buffer: TinyVec::new(), ready: 0..0, } } @@ -51,7 +51,7 @@ pub fn new_compatible>(iter: I) -> Decompositions { Decompositions { kind: self::DecompositionType::Compatible, iter: iter.fuse(), - buffer: SmallVec::new(), + buffer: TinyVec::new(), ready: 0..0, } } @@ -78,8 +78,8 @@ impl Decompositions { #[inline] fn reset_buffer(&mut self) { - // Equivalent to `self.buffer.drain(0..self.ready.end)` (if SmallVec - // supported this API) + // Equivalent to `self.buffer.drain(0..self.ready.end)` + // but faster than drain() if the buffer is a SmallVec or TinyVec let pending = self.buffer.len() - self.ready.end; for i in 0..pending { self.buffer[i] = self.buffer[i + self.ready.end]; diff --git a/src/lib.rs b/src/lib.rs index a86ade1..56142a2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,7 +41,7 @@ #![doc(html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png", html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png")] -extern crate smallvec; +extern crate tinyvec; pub use tables::UNICODE_VERSION; pub use decompose::Decompositions; diff --git a/src/recompose.rs b/src/recompose.rs index 4c2bf97..40b20dc 100644 --- a/src/recompose.rs +++ b/src/recompose.rs @@ -9,7 +9,7 @@ // except according to those terms. use decompose::Decompositions; -use smallvec::SmallVec; +use tinyvec::TinyVec; use std::fmt::{self, Write}; #[derive(Clone)] @@ -24,7 +24,7 @@ enum RecompositionState { pub struct Recompositions { iter: Decompositions, state: RecompositionState, - buffer: SmallVec<[char; 4]>, + buffer: TinyVec<[char; 4]>, composee: Option, last_ccc: Option, } @@ -34,7 +34,7 @@ pub fn new_canonical>(iter: I) -> Recompositions { Recompositions { iter: super::decompose::new_canonical(iter), state: self::RecompositionState::Composing, - buffer: SmallVec::new(), + buffer: TinyVec::new(), composee: None, last_ccc: None, } @@ -45,7 +45,7 @@ pub fn new_compatible>(iter: I) -> Recompositions { Recompositions { iter: super::decompose::new_compatible(iter), state: self::RecompositionState::Composing, - buffer: SmallVec::new(), + buffer: TinyVec::new(), composee: None, last_ccc: None, }