Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Switch from SmallVec to 100% safe TinyVec#54

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Manishearth merged 4 commits intounicode-rs:masterfromShnatsel:tinyvec
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes fromall 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
5 changes: 3 additions & 2 deletionsCargo.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"]
12 changes: 6 additions & 6 deletionssrc/decompose.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@
// <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.
usesmallvec::SmallVec;
usetinyvec::TinyVec;
use std::fmt::{self,Write};
use std::iter::Fuse;
use std::ops::Range;
Expand All@@ -32,7 +32,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:TinyVec<[(u8,char);4]>,
ready:Range<usize>,
}

Expand All@@ -41,7 +41,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:TinyVec::new(),
ready:0..0,
}
}
Expand All@@ -51,7 +51,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:TinyVec::new(),
ready:0..0,
}
}
Expand All@@ -78,8 +78,8 @@ impl<I> Decompositions<I> {

#[inline]
fnreset_buffer(&mutself){
// 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 iin0..pending{
self.buffer[i] =self.buffer[i +self.ready.end];
Expand Down
2 changes: 1 addition & 1 deletionsrc/lib.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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")]

externcratesmallvec;
externcratetinyvec;

pubuse tables::UNICODE_VERSION;
pubuse decompose::Decompositions;
Expand Down
8 changes: 4 additions & 4 deletionssrc/recompose.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@
// except according to those terms.

use decompose::Decompositions;
usesmallvec::SmallVec;
usetinyvec::TinyVec;
use std::fmt::{self,Write};

#[derive(Clone)]
Expand All@@ -24,7 +24,7 @@ enum RecompositionState {
pubstructRecompositions<I>{
iter:Decompositions<I>,
state:RecompositionState,
buffer:SmallVec<[char;4]>,
buffer:TinyVec<[char;4]>,
composee:Option<char>,
last_ccc:Option<u8>,
}
Expand All@@ -34,7 +34,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:TinyVec::new(),
composee:None,
last_ccc:None,
}
Expand All@@ -45,7 +45,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:TinyVec::new(),
composee:None,
last_ccc:None,
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp