Skip to content

Commit 635e0f6

Browse files
authored
unicode: regenerate DFAs to make use of once_cell
The latest version of ucd-generate now uses once_cell instead of lazy_static. So we re-generate the DFAs to bring in that change and drop the lazy_static dependency. Closes #124
1 parent 77105cf commit 635e0f6

File tree

9 files changed

+82
-114
lines changed

9 files changed

+82
-114
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ bench = false
2525
default = ["std", "unicode"]
2626
std = ["alloc", "memchr/std", "serde?/std"]
2727
alloc = ["serde?/alloc"]
28-
unicode = ["dep:lazy_static", "dep:regex-automata"]
28+
unicode = ["dep:once_cell", "dep:regex-automata"]
2929
serde = ["dep:serde"]
3030

3131
[dependencies]
3232
memchr = { version = "2.4.0", default-features = false }
33-
lazy_static = { version = "1.2.0", optional = true }
33+
once_cell = { version = "1.14.0", optional = true }
3434
regex-automata = { version = "0.1.5", default-features = false, optional = true }
3535
serde = { version = "1.0.85", default-features = false, optional = true }
3636

src/unicode/fsm/grapheme_break_fwd.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// ucd-generate 0.2.12 is available on crates.io.
66

77
#[cfg(target_endian = "big")]
8-
lazy_static::lazy_static! {
9-
pub static ref GRAPHEME_BREAK_FWD: ::regex_automata::SparseDFA<&'static [u8], u16> = {
8+
pub static GRAPHEME_BREAK_FWD: ::once_cell::sync::Lazy<
9+
::regex_automata::SparseDFA<&'static [u8], u16>,
10+
> = ::once_cell::sync::Lazy::new(|| {
1011
#[repr(C)]
1112
struct Aligned<B: ?Sized> {
1213
_align: [u8; 0],
@@ -18,15 +19,13 @@ lazy_static::lazy_static! {
1819
bytes: *include_bytes!("grapheme_break_fwd.bigendian.dfa"),
1920
};
2021

21-
unsafe {
22-
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
23-
}
24-
};
25-
}
22+
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
23+
});
2624

2725
#[cfg(target_endian = "little")]
28-
lazy_static::lazy_static! {
29-
pub static ref GRAPHEME_BREAK_FWD: ::regex_automata::SparseDFA<&'static [u8], u16> = {
26+
pub static GRAPHEME_BREAK_FWD: ::once_cell::sync::Lazy<
27+
::regex_automata::SparseDFA<&'static [u8], u16>,
28+
> = ::once_cell::sync::Lazy::new(|| {
3029
#[repr(C)]
3130
struct Aligned<B: ?Sized> {
3231
_align: [u8; 0],
@@ -38,8 +37,5 @@ lazy_static::lazy_static! {
3837
bytes: *include_bytes!("grapheme_break_fwd.littleendian.dfa"),
3938
};
4039

41-
unsafe {
42-
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
43-
}
44-
};
45-
}
40+
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
41+
});

src/unicode/fsm/grapheme_break_rev.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// ucd-generate 0.2.12 is available on crates.io.
66

77
#[cfg(target_endian = "big")]
8-
lazy_static::lazy_static! {
9-
pub static ref GRAPHEME_BREAK_REV: ::regex_automata::SparseDFA<&'static [u8], u16> = {
8+
pub static GRAPHEME_BREAK_REV: ::once_cell::sync::Lazy<
9+
::regex_automata::SparseDFA<&'static [u8], u16>,
10+
> = ::once_cell::sync::Lazy::new(|| {
1011
#[repr(C)]
1112
struct Aligned<B: ?Sized> {
1213
_align: [u8; 0],
@@ -18,15 +19,13 @@ lazy_static::lazy_static! {
1819
bytes: *include_bytes!("grapheme_break_rev.bigendian.dfa"),
1920
};
2021

21-
unsafe {
22-
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
23-
}
24-
};
25-
}
22+
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
23+
});
2624

2725
#[cfg(target_endian = "little")]
28-
lazy_static::lazy_static! {
29-
pub static ref GRAPHEME_BREAK_REV: ::regex_automata::SparseDFA<&'static [u8], u16> = {
26+
pub static GRAPHEME_BREAK_REV: ::once_cell::sync::Lazy<
27+
::regex_automata::SparseDFA<&'static [u8], u16>,
28+
> = ::once_cell::sync::Lazy::new(|| {
3029
#[repr(C)]
3130
struct Aligned<B: ?Sized> {
3231
_align: [u8; 0],
@@ -38,8 +37,5 @@ lazy_static::lazy_static! {
3837
bytes: *include_bytes!("grapheme_break_rev.littleendian.dfa"),
3938
};
4039

41-
unsafe {
42-
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
43-
}
44-
};
45-
}
40+
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
41+
});

src/unicode/fsm/regional_indicator_rev.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// ucd-generate 0.2.12 is available on crates.io.
66

77
#[cfg(target_endian = "big")]
8-
lazy_static::lazy_static! {
9-
pub static ref REGIONAL_INDICATOR_REV: ::regex_automata::DenseDFA<&'static [u8], u8> = {
8+
pub static REGIONAL_INDICATOR_REV: ::once_cell::sync::Lazy<
9+
::regex_automata::DenseDFA<&'static [u8], u8>,
10+
> = ::once_cell::sync::Lazy::new(|| {
1011
#[repr(C)]
1112
struct Aligned<B: ?Sized> {
1213
_align: [u8; 0],
@@ -18,15 +19,13 @@ lazy_static::lazy_static! {
1819
bytes: *include_bytes!("regional_indicator_rev.bigendian.dfa"),
1920
};
2021

21-
unsafe {
22-
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
23-
}
24-
};
25-
}
22+
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
23+
});
2624

2725
#[cfg(target_endian = "little")]
28-
lazy_static::lazy_static! {
29-
pub static ref REGIONAL_INDICATOR_REV: ::regex_automata::DenseDFA<&'static [u8], u8> = {
26+
pub static REGIONAL_INDICATOR_REV: ::once_cell::sync::Lazy<
27+
::regex_automata::DenseDFA<&'static [u8], u8>,
28+
> = ::once_cell::sync::Lazy::new(|| {
3029
#[repr(C)]
3130
struct Aligned<B: ?Sized> {
3231
_align: [u8; 0],
@@ -38,8 +37,5 @@ lazy_static::lazy_static! {
3837
bytes: *include_bytes!("regional_indicator_rev.littleendian.dfa"),
3938
};
4039

41-
unsafe {
42-
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
43-
}
44-
};
45-
}
40+
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
41+
});

src/unicode/fsm/sentence_break_fwd.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// ucd-generate 0.2.12 is available on crates.io.
66

77
#[cfg(target_endian = "big")]
8-
lazy_static::lazy_static! {
9-
pub static ref SENTENCE_BREAK_FWD: ::regex_automata::SparseDFA<&'static [u8], u32> = {
8+
pub static SENTENCE_BREAK_FWD: ::once_cell::sync::Lazy<
9+
::regex_automata::SparseDFA<&'static [u8], u32>,
10+
> = ::once_cell::sync::Lazy::new(|| {
1011
#[repr(C)]
1112
struct Aligned<B: ?Sized> {
1213
_align: [u8; 0],
@@ -18,15 +19,13 @@ lazy_static::lazy_static! {
1819
bytes: *include_bytes!("sentence_break_fwd.bigendian.dfa"),
1920
};
2021

21-
unsafe {
22-
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
23-
}
24-
};
25-
}
22+
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
23+
});
2624

2725
#[cfg(target_endian = "little")]
28-
lazy_static::lazy_static! {
29-
pub static ref SENTENCE_BREAK_FWD: ::regex_automata::SparseDFA<&'static [u8], u32> = {
26+
pub static SENTENCE_BREAK_FWD: ::once_cell::sync::Lazy<
27+
::regex_automata::SparseDFA<&'static [u8], u32>,
28+
> = ::once_cell::sync::Lazy::new(|| {
3029
#[repr(C)]
3130
struct Aligned<B: ?Sized> {
3231
_align: [u8; 0],
@@ -38,8 +37,5 @@ lazy_static::lazy_static! {
3837
bytes: *include_bytes!("sentence_break_fwd.littleendian.dfa"),
3938
};
4039

41-
unsafe {
42-
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
43-
}
44-
};
45-
}
40+
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
41+
});

src/unicode/fsm/simple_word_fwd.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// ucd-generate 0.2.12 is available on crates.io.
66

77
#[cfg(target_endian = "big")]
8-
lazy_static::lazy_static! {
9-
pub static ref SIMPLE_WORD_FWD: ::regex_automata::SparseDFA<&'static [u8], u16> = {
8+
pub static SIMPLE_WORD_FWD: ::once_cell::sync::Lazy<
9+
::regex_automata::SparseDFA<&'static [u8], u16>,
10+
> = ::once_cell::sync::Lazy::new(|| {
1011
#[repr(C)]
1112
struct Aligned<B: ?Sized> {
1213
_align: [u8; 0],
@@ -18,15 +19,13 @@ lazy_static::lazy_static! {
1819
bytes: *include_bytes!("simple_word_fwd.bigendian.dfa"),
1920
};
2021

21-
unsafe {
22-
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
23-
}
24-
};
25-
}
22+
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
23+
});
2624

2725
#[cfg(target_endian = "little")]
28-
lazy_static::lazy_static! {
29-
pub static ref SIMPLE_WORD_FWD: ::regex_automata::SparseDFA<&'static [u8], u16> = {
26+
pub static SIMPLE_WORD_FWD: ::once_cell::sync::Lazy<
27+
::regex_automata::SparseDFA<&'static [u8], u16>,
28+
> = ::once_cell::sync::Lazy::new(|| {
3029
#[repr(C)]
3130
struct Aligned<B: ?Sized> {
3231
_align: [u8; 0],
@@ -38,8 +37,5 @@ lazy_static::lazy_static! {
3837
bytes: *include_bytes!("simple_word_fwd.littleendian.dfa"),
3938
};
4039

41-
unsafe {
42-
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
43-
}
44-
};
45-
}
40+
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
41+
});

src/unicode/fsm/whitespace_anchored_fwd.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// ucd-generate 0.2.12 is available on crates.io.
66

77
#[cfg(target_endian = "big")]
8-
lazy_static::lazy_static! {
9-
pub static ref WHITESPACE_ANCHORED_FWD: ::regex_automata::DenseDFA<&'static [u8], u8> = {
8+
pub static WHITESPACE_ANCHORED_FWD: ::once_cell::sync::Lazy<
9+
::regex_automata::DenseDFA<&'static [u8], u8>,
10+
> = ::once_cell::sync::Lazy::new(|| {
1011
#[repr(C)]
1112
struct Aligned<B: ?Sized> {
1213
_align: [u8; 0],
@@ -18,15 +19,13 @@ lazy_static::lazy_static! {
1819
bytes: *include_bytes!("whitespace_anchored_fwd.bigendian.dfa"),
1920
};
2021

21-
unsafe {
22-
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
23-
}
24-
};
25-
}
22+
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
23+
});
2624

2725
#[cfg(target_endian = "little")]
28-
lazy_static::lazy_static! {
29-
pub static ref WHITESPACE_ANCHORED_FWD: ::regex_automata::DenseDFA<&'static [u8], u8> = {
26+
pub static WHITESPACE_ANCHORED_FWD: ::once_cell::sync::Lazy<
27+
::regex_automata::DenseDFA<&'static [u8], u8>,
28+
> = ::once_cell::sync::Lazy::new(|| {
3029
#[repr(C)]
3130
struct Aligned<B: ?Sized> {
3231
_align: [u8; 0],
@@ -38,8 +37,5 @@ lazy_static::lazy_static! {
3837
bytes: *include_bytes!("whitespace_anchored_fwd.littleendian.dfa"),
3938
};
4039

41-
unsafe {
42-
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
43-
}
44-
};
45-
}
40+
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
41+
});

src/unicode/fsm/whitespace_anchored_rev.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// ucd-generate 0.2.12 is available on crates.io.
66

77
#[cfg(target_endian = "big")]
8-
lazy_static::lazy_static! {
9-
pub static ref WHITESPACE_ANCHORED_REV: ::regex_automata::DenseDFA<&'static [u16], u16> = {
8+
pub static WHITESPACE_ANCHORED_REV: ::once_cell::sync::Lazy<
9+
::regex_automata::DenseDFA<&'static [u16], u16>,
10+
> = ::once_cell::sync::Lazy::new(|| {
1011
#[repr(C)]
1112
struct Aligned<B: ?Sized> {
1213
_align: [u16; 0],
@@ -18,15 +19,13 @@ lazy_static::lazy_static! {
1819
bytes: *include_bytes!("whitespace_anchored_rev.bigendian.dfa"),
1920
};
2021

21-
unsafe {
22-
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
23-
}
24-
};
25-
}
22+
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
23+
});
2624

2725
#[cfg(target_endian = "little")]
28-
lazy_static::lazy_static! {
29-
pub static ref WHITESPACE_ANCHORED_REV: ::regex_automata::DenseDFA<&'static [u16], u16> = {
26+
pub static WHITESPACE_ANCHORED_REV: ::once_cell::sync::Lazy<
27+
::regex_automata::DenseDFA<&'static [u16], u16>,
28+
> = ::once_cell::sync::Lazy::new(|| {
3029
#[repr(C)]
3130
struct Aligned<B: ?Sized> {
3231
_align: [u16; 0],
@@ -38,8 +37,5 @@ lazy_static::lazy_static! {
3837
bytes: *include_bytes!("whitespace_anchored_rev.littleendian.dfa"),
3938
};
4039

41-
unsafe {
42-
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
43-
}
44-
};
45-
}
40+
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
41+
});

src/unicode/fsm/word_break_fwd.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// ucd-generate 0.2.12 is available on crates.io.
66

77
#[cfg(target_endian = "big")]
8-
lazy_static::lazy_static! {
9-
pub static ref WORD_BREAK_FWD: ::regex_automata::SparseDFA<&'static [u8], u32> = {
8+
pub static WORD_BREAK_FWD: ::once_cell::sync::Lazy<
9+
::regex_automata::SparseDFA<&'static [u8], u32>,
10+
> = ::once_cell::sync::Lazy::new(|| {
1011
#[repr(C)]
1112
struct Aligned<B: ?Sized> {
1213
_align: [u8; 0],
@@ -18,15 +19,13 @@ lazy_static::lazy_static! {
1819
bytes: *include_bytes!("word_break_fwd.bigendian.dfa"),
1920
};
2021

21-
unsafe {
22-
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
23-
}
24-
};
25-
}
22+
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
23+
});
2624

2725
#[cfg(target_endian = "little")]
28-
lazy_static::lazy_static! {
29-
pub static ref WORD_BREAK_FWD: ::regex_automata::SparseDFA<&'static [u8], u32> = {
26+
pub static WORD_BREAK_FWD: ::once_cell::sync::Lazy<
27+
::regex_automata::SparseDFA<&'static [u8], u32>,
28+
> = ::once_cell::sync::Lazy::new(|| {
3029
#[repr(C)]
3130
struct Aligned<B: ?Sized> {
3231
_align: [u8; 0],
@@ -38,8 +37,5 @@ lazy_static::lazy_static! {
3837
bytes: *include_bytes!("word_break_fwd.littleendian.dfa"),
3938
};
4039

41-
unsafe {
42-
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
43-
}
44-
};
45-
}
40+
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
41+
});

0 commit comments

Comments
 (0)