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

Commit0d09a94

Browse files
authored
Merge pull request#54 from Shnatsel/tinyvec
Switch from SmallVec to 100% safe TinyVec
2 parents59febeb +f5712b7 commit0d09a94

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

‎Cargo.toml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ Unicode Standard Annex #15.
2020

2121
exclude = ["target/*","Cargo.lock","scripts/tmp","*.txt","tests/*" ]
2222

23-
[dependencies]
24-
smallvec ="1.1"
23+
[dependencies.tinyvec]
24+
version ="0.3.2"
25+
features = ["alloc"]

‎src/decompose.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
usesmallvec::SmallVec;
10+
usetinyvec::TinyVec;
1111
use std::fmt::{self,Write};
1212
use std::iter::Fuse;
1313
use std::ops::Range;
@@ -32,7 +32,7 @@ pub struct Decompositions<I> {
3232
// 2) "Ready" characters which are sorted and ready to emit on demand;
3333
// 3) A "pending" block which stills needs more characters for us to be able
3434
// to sort in canonical order and is not safe to emit.
35-
buffer:SmallVec<[(u8,char);4]>,
35+
buffer:TinyVec<[(u8,char);4]>,
3636
ready:Range<usize>,
3737
}
3838

@@ -41,7 +41,7 @@ pub fn new_canonical<I: Iterator<Item=char>>(iter: I) -> Decompositions<I> {
4141
Decompositions{
4242
kind:self::DecompositionType::Canonical,
4343
iter: iter.fuse(),
44-
buffer:SmallVec::new(),
44+
buffer:TinyVec::new(),
4545
ready:0..0,
4646
}
4747
}
@@ -51,7 +51,7 @@ pub fn new_compatible<I: Iterator<Item=char>>(iter: I) -> Decompositions<I> {
5151
Decompositions{
5252
kind:self::DecompositionType::Compatible,
5353
iter: iter.fuse(),
54-
buffer:SmallVec::new(),
54+
buffer:TinyVec::new(),
5555
ready:0..0,
5656
}
5757
}
@@ -78,8 +78,8 @@ impl<I> Decompositions<I> {
7878

7979
#[inline]
8080
fnreset_buffer(&mutself){
81-
// Equivalent to `self.buffer.drain(0..self.ready.end)` (if SmallVec
82-
//supported this API)
81+
// Equivalent to `self.buffer.drain(0..self.ready.end)`
82+
//but faster than drain() if the buffer is a SmallVec or TinyVec
8383
let pending =self.buffer.len() -self.ready.end;
8484
for iin0..pending{
8585
self.buffer[i] =self.buffer[i +self.ready.end];

‎src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#![doc(html_logo_url ="https://unicode-rs.github.io/unicode-rs_sm.png",
4242
html_favicon_url ="https://unicode-rs.github.io/unicode-rs_sm.png")]
4343

44-
externcratesmallvec;
44+
externcratetinyvec;
4545

4646
pubuse tables::UNICODE_VERSION;
4747
pubuse decompose::Decompositions;

‎src/recompose.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use decompose::Decompositions;
12-
usesmallvec::SmallVec;
12+
usetinyvec::TinyVec;
1313
use std::fmt::{self,Write};
1414

1515
#[derive(Clone)]
@@ -24,7 +24,7 @@ enum RecompositionState {
2424
pubstructRecompositions<I>{
2525
iter:Decompositions<I>,
2626
state:RecompositionState,
27-
buffer:SmallVec<[char;4]>,
27+
buffer:TinyVec<[char;4]>,
2828
composee:Option<char>,
2929
last_ccc:Option<u8>,
3030
}
@@ -34,7 +34,7 @@ pub fn new_canonical<I: Iterator<Item=char>>(iter: I) -> Recompositions<I> {
3434
Recompositions{
3535
iter:super::decompose::new_canonical(iter),
3636
state:self::RecompositionState::Composing,
37-
buffer:SmallVec::new(),
37+
buffer:TinyVec::new(),
3838
composee:None,
3939
last_ccc:None,
4040
}
@@ -45,7 +45,7 @@ pub fn new_compatible<I: Iterator<Item=char>>(iter: I) -> Recompositions<I> {
4545
Recompositions{
4646
iter:super::decompose::new_compatible(iter),
4747
state:self::RecompositionState::Composing,
48-
buffer:SmallVec::new(),
48+
buffer:TinyVec::new(),
4949
composee:None,
5050
last_ccc:None,
5151
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp