Skip to content

Commit

Permalink
unicode: regenerate DFAs to make use of once_cell
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dtolnay committed Sep 3, 2022
1 parent 77105cf commit 635e0f6
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 114 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -25,12 +25,12 @@ bench = false
default = ["std", "unicode"]
std = ["alloc", "memchr/std", "serde?/std"]
alloc = ["serde?/alloc"]
unicode = ["dep:lazy_static", "dep:regex-automata"]
unicode = ["dep:once_cell", "dep:regex-automata"]
serde = ["dep:serde"]

[dependencies]
memchr = { version = "2.4.0", default-features = false }
lazy_static = { version = "1.2.0", optional = true }
once_cell = { version = "1.14.0", optional = true }
regex-automata = { version = "0.1.5", default-features = false, optional = true }
serde = { version = "1.0.85", default-features = false, optional = true }

Expand Down
24 changes: 10 additions & 14 deletions src/unicode/fsm/grapheme_break_fwd.rs
Expand Up @@ -5,8 +5,9 @@
// ucd-generate 0.2.12 is available on crates.io.

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

unsafe {
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
});

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

unsafe {
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
});
24 changes: 10 additions & 14 deletions src/unicode/fsm/grapheme_break_rev.rs
Expand Up @@ -5,8 +5,9 @@
// ucd-generate 0.2.12 is available on crates.io.

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

unsafe {
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
});

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

unsafe {
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
});
24 changes: 10 additions & 14 deletions src/unicode/fsm/regional_indicator_rev.rs
Expand Up @@ -5,8 +5,9 @@
// ucd-generate 0.2.12 is available on crates.io.

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

unsafe {
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
});

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

unsafe {
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
});
24 changes: 10 additions & 14 deletions src/unicode/fsm/sentence_break_fwd.rs
Expand Up @@ -5,8 +5,9 @@
// ucd-generate 0.2.12 is available on crates.io.

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

unsafe {
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
});

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

unsafe {
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
});
24 changes: 10 additions & 14 deletions src/unicode/fsm/simple_word_fwd.rs
Expand Up @@ -5,8 +5,9 @@
// ucd-generate 0.2.12 is available on crates.io.

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

unsafe {
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
});

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

unsafe {
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
});
24 changes: 10 additions & 14 deletions src/unicode/fsm/whitespace_anchored_fwd.rs
Expand Up @@ -5,8 +5,9 @@
// ucd-generate 0.2.12 is available on crates.io.

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

unsafe {
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
});

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

unsafe {
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
});
24 changes: 10 additions & 14 deletions src/unicode/fsm/whitespace_anchored_rev.rs
Expand Up @@ -5,8 +5,9 @@
// ucd-generate 0.2.12 is available on crates.io.

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

unsafe {
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
});

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

unsafe {
::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::DenseDFA::from_bytes(&ALIGNED.bytes) }
});
24 changes: 10 additions & 14 deletions src/unicode/fsm/word_break_fwd.rs
Expand Up @@ -5,8 +5,9 @@
// ucd-generate 0.2.12 is available on crates.io.

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

unsafe {
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
});

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

unsafe {
::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes)
}
};
}
unsafe { ::regex_automata::SparseDFA::from_bytes(&ALIGNED.bytes) }
});

0 comments on commit 635e0f6

Please sign in to comment.