diff --git a/Cargo.toml b/Cargo.toml index f86f4c03..79e744ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ log = "0.4" serde = { version = "1.0", features = ["derive"] } memchr = "2.4" memmap2 = { version = "0.9.0", optional = true } +tinyvec = "1.8.1" [dev-dependencies] env_logger = "0.11" diff --git a/src/maxminddb/lib.rs b/src/maxminddb/lib.rs index b9705c05..86d5f77d 100644 --- a/src/maxminddb/lib.rs +++ b/src/maxminddb/lib.rs @@ -10,6 +10,7 @@ use std::path::Path; use ipnetwork::IpNetwork; use serde::{de, Deserialize, Serialize}; +use tinyvec::ArrayVec; #[cfg(feature = "mmap")] pub use memmap2::Mmap; @@ -78,7 +79,7 @@ pub struct Metadata { #[derive(Debug)] struct WithinNode { node: usize, - ip_bytes: Vec, + ip_bytes: ArrayVec<[u8; 16]>, prefix_len: usize, } @@ -346,7 +347,7 @@ impl<'de, S: AsRef<[u8]>> Reader { // traversed to as our to be processed stack. stack.push(WithinNode { node, - ip_bytes, + ip_bytes: ArrayVec::<[u8; 16]>::from_iter(ip_bytes), prefix_len, }); }