Upgrade rust/crates/regex-automata to 0.1.10
Test: make
Change-Id: Iba14ce63ff5be85b611cd1768692d8fb6a2aa6e8
diff --git a/src/byteorder.rs b/src/byteorder.rs
new file mode 100644
index 0000000..e909f93
--- /dev/null
+++ b/src/byteorder.rs
@@ -0,0 +1,76 @@
+use core::convert::TryInto;
+
+pub trait ByteOrder {
+ fn read_u16(buf: &[u8]) -> u16;
+ fn read_u32(buf: &[u8]) -> u32;
+ fn read_u64(buf: &[u8]) -> u64;
+ fn read_uint(buf: &[u8], nbytes: usize) -> u64;
+ fn write_u16(buf: &mut [u8], n: u16);
+ fn write_u32(buf: &mut [u8], n: u32);
+ fn write_u64(buf: &mut [u8], n: u64);
+ fn write_uint(buf: &mut [u8], n: u64, nbytes: usize);
+}
+
+pub enum BigEndian {}
+pub enum LittleEndian {}
+pub enum NativeEndian {}
+
+macro_rules! impl_endian {
+ ($t:ty, $from_endian:ident, $to_endian:ident) => {
+ impl ByteOrder for $t {
+ #[inline]
+ fn read_u16(buf: &[u8]) -> u16 {
+ u16::$from_endian(buf[0..2].try_into().unwrap())
+ }
+
+ #[inline]
+ fn read_u32(buf: &[u8]) -> u32 {
+ u32::$from_endian(buf[0..4].try_into().unwrap())
+ }
+
+ #[inline]
+ fn read_u64(buf: &[u8]) -> u64 {
+ u64::$from_endian(buf[0..8].try_into().unwrap())
+ }
+
+ #[inline]
+ fn read_uint(buf: &[u8], nbytes: usize) -> u64 {
+ let mut dst = [0u8; 8];
+ dst[..nbytes].copy_from_slice(&buf[..nbytes]);
+ u64::$from_endian(dst)
+ }
+
+ #[inline]
+ fn write_u16(buf: &mut [u8], n: u16) {
+ buf[0..2].copy_from_slice(&n.$to_endian()[..]);
+ }
+
+ #[inline]
+ fn write_u32(buf: &mut [u8], n: u32) {
+ buf[0..4].copy_from_slice(&n.$to_endian()[..]);
+ }
+
+ #[inline]
+ fn write_u64(buf: &mut [u8], n: u64) {
+ buf[0..8].copy_from_slice(&n.$to_endian()[..]);
+ }
+
+ #[inline]
+ fn write_uint(buf: &mut [u8], n: u64, nbytes: usize) {
+ buf[..nbytes].copy_from_slice(&n.$to_endian()[..nbytes]);
+ }
+ }
+ };
+}
+
+impl_endian! {
+ BigEndian, from_be_bytes, to_be_bytes
+}
+
+impl_endian! {
+ LittleEndian, from_le_bytes, to_le_bytes
+}
+
+impl_endian! {
+ NativeEndian, from_ne_bytes, to_ne_bytes
+}
diff --git a/src/determinize.rs b/src/determinize.rs
index f300316..cf0c285 100644
--- a/src/determinize.rs
+++ b/src/determinize.rs
@@ -148,7 +148,8 @@
if let Some(&cached_id) = self.cache.get(&state) {
// Since we have a cached state, put the constructed state's
// memory back into our scratch space, so that it can be reused.
- mem::replace(&mut self.scratch_nfa_states, state.nfa_states);
+ let _ =
+ mem::replace(&mut self.scratch_nfa_states, state.nfa_states);
return Ok((cached_id, false));
}
// Nothing was in the cache, so add this state to the cache.
diff --git a/src/lib.rs b/src/lib.rs
index 4d3e9c1..7894ecc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -290,7 +290,6 @@
#[cfg(all(test, feature = "transducer"))]
extern crate bstr;
-extern crate byteorder;
#[cfg(feature = "transducer")]
extern crate fst;
#[cfg(feature = "std")]
@@ -306,6 +305,7 @@
pub use sparse::SparseDFA;
pub use state_id::StateID;
+mod byteorder;
mod classes;
#[path = "dense.rs"]
mod dense_imp;
diff --git a/src/sparse_set.rs b/src/sparse_set.rs
index 6f145ba..56743b0 100644
--- a/src/sparse_set.rs
+++ b/src/sparse_set.rs
@@ -6,7 +6,7 @@
/// entire set can also be done in constant time. Iteration yields elements
/// in the order in which they were inserted.
///
-/// The data structure is based on: http://research.swtch.com/sparse
+/// The data structure is based on: https://research.swtch.com/sparse
/// Note though that we don't actually use uninitialized memory. We generally
/// reuse sparse sets, so the initial allocation cost is bareable. However, its
/// other properties listed above are extremely useful.