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

RFC: Switch from tinyvec to smallvec#85

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

Open
emilio wants to merge2 commits intounicode-rs:master
base:master
Choose a base branch
Loading
fromemilio:smallvec
Open
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
8 changes: 3 additions & 5 deletionsCargo.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
[package]

name = "unicode-normalization"
version = "0.1.19"
version = "0.1.20"
authors = ["kwantam <kwantam@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>"]

homepage = "https://github.com/unicode-rs/unicode-normalization"
Expand All@@ -22,10 +22,8 @@ edition = "2018"

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

[dependencies.tinyvec]
version = "1"
features = ["alloc"]

[dependencies]
smallvec = "1"

[features]
default = ["std"]
Expand Down
25 changes: 12 additions & 13 deletionssrc/decompose.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
use core::fmt::{self, Write};
use core::iter::Fuse;
use core::ops::Range;
usetinyvec::TinyVec;
usesmallvec::SmallVec;

#[derive(Clone)]
enum DecompositionType {
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:TinyVec<[(u8, char); 4]>,
buffer:SmallVec<[(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:TinyVec::new(),
buffer:Default::default(),
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:TinyVec::new(),
buffer:Default::default(),
ready: 0..0,
}
}
Expand DownExpand Up@@ -116,16 +116,15 @@ impl<I: Iterator<Item = char>> Iterator for Decompositions<I> {
(None, _) => {
if self.buffer.is_empty() {
return None;
} else {
self.sort_pending();
self.ready.end = self.buffer.len();

// This implementation means that we can call `next`
// on an exhausted iterator; the last outer `next` call
// will result in an inner `next` call. To make this
// safe, we use `fuse`.
break;
}
self.sort_pending();
self.ready.end = self.buffer.len();

// This implementation means that we can call `next`
// on an exhausted iterator; the last outer `next` call
// will result in an inner `next` call. To make this
// safe, we use `fuse`.
break;
}
}
}
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@@ -50,7 +50,7 @@ extern crate alloc;
#[cfg(feature = "std")]
extern crate core;

extern cratetinyvec;
extern cratesmallvec;

pub use crate::decompose::Decompositions;
pub use crate::quick_check::{
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@@ -10,7 +10,7 @@

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

#[derive(Clone)]
enum RecompositionState {
Expand All@@ -24,7 +24,7 @@ enum RecompositionState {
pub struct Recompositions<I> {
iter: Decompositions<I>,
state: RecompositionState,
buffer:TinyVec<[char; 4]>,
buffer:SmallVec<[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:TinyVec::new(),
buffer:SmallVec::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:TinyVec::new(),
buffer:SmallVec::new(),
composee: None,
last_ccc: None,
}
Expand Down
4 changes: 2 additions & 2 deletionssrc/replace.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::fmt::{self, Write};
usetinyvec::ArrayVec;
usesmallvec::SmallVec;

/// External iterator for replacements for a string's characters.
#[derive(Clone)]
Expand DownExpand Up@@ -36,7 +36,7 @@ impl<I: Iterator<Item = char>> Iterator for Replacements<I> {
match self.iter.next() {
Some(ch) => {
// At this time, the longest replacement sequence has length 2.
let mut buffer =ArrayVec::<[char; 2]>::new();
let mut buffer =SmallVec::<[char; 2]>::new();
super::char::decompose_cjk_compat_variants(ch, |d| buffer.push(d));
self.buffer = buffer.get(1).copied();
Some(buffer[0])
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp