Skip to content

Remove usage of smallvec #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ Unicode Standard Annex #15.
exclude = [ "target/*", "Cargo.lock", "scripts/tmp", "*.txt", "src/normalization_tests.rs", "src/test.rs" ]

[dependencies]
smallvec = "0.6"
15 changes: 4 additions & 11 deletions src/decompose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use smallvec::SmallVec;
use std::fmt::{self, Write};
use std::iter::Fuse;
use std::ops::Range;
Expand All @@ -32,7 +31,7 @@ pub struct Decompositions<I> {
// 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: Vec<(u8, char)>,
ready: Range<usize>,
}

Expand All @@ -41,7 +40,7 @@ pub fn new_canonical<I: Iterator<Item=char>>(iter: I) -> Decompositions<I> {
Decompositions {
kind: self::DecompositionType::Canonical,
iter: iter.fuse(),
buffer: SmallVec::new(),
buffer: Vec::with_capacity(4),
ready: 0..0,
}
}
Expand All @@ -51,7 +50,7 @@ pub fn new_compatible<I: Iterator<Item=char>>(iter: I) -> Decompositions<I> {
Decompositions {
kind: self::DecompositionType::Compatible,
iter: iter.fuse(),
buffer: SmallVec::new(),
buffer: Vec::with_capacity(4),
ready: 0..0,
}
}
Expand All @@ -78,13 +77,7 @@ impl<I> Decompositions<I> {

#[inline]
fn reset_buffer(&mut self) {
// Equivalent to `self.buffer.drain(0..self.ready.end)` (if SmallVec
// supported this API)
let pending = self.buffer.len() - self.ready.end;
for i in 0..pending {
self.buffer[i] = self.buffer[i + self.ready.end];
}
self.buffer.truncate(pending);
let _ = self.buffer.drain(0..self.ready.end).count();
self.ready = 0..0;
}

Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
#![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;

pub use tables::UNICODE_VERSION;
pub use decompose::Decompositions;
pub use quick_check::{
Expand Down
7 changes: 3 additions & 4 deletions src/recompose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

use decompose::Decompositions;
use smallvec::SmallVec;
use std::fmt::{self, Write};

#[derive(Clone)]
Expand All @@ -24,7 +23,7 @@ enum RecompositionState {
pub struct Recompositions<I> {
iter: Decompositions<I>,
state: RecompositionState,
buffer: SmallVec<[char; 4]>,
buffer: Vec<char>,
composee: Option<char>,
last_ccc: Option<u8>,
}
Expand All @@ -34,7 +33,7 @@ pub fn new_canonical<I: Iterator<Item=char>>(iter: I) -> Recompositions<I> {
Recompositions {
iter: super::decompose::new_canonical(iter),
state: self::RecompositionState::Composing,
buffer: SmallVec::new(),
buffer: Vec::with_capacity(4),
composee: None,
last_ccc: None,
}
Expand All @@ -45,7 +44,7 @@ pub fn new_compatible<I: Iterator<Item=char>>(iter: I) -> Recompositions<I> {
Recompositions {
iter: super::decompose::new_compatible(iter),
state: self::RecompositionState::Composing,
buffer: SmallVec::new(),
buffer: Vec::with_capacity(4),
composee: None,
last_ccc: None,
}
Expand Down