From 87839cbbaf707d0315af989064141267517088fc Mon Sep 17 00:00:00 2001 From: Aria Shrimpton Date: Mon, 11 Mar 2024 00:45:18 +0000 Subject: inline adaptive container functions --- src/crates/library/src/adaptive.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/crates/library/src/adaptive.rs b/src/crates/library/src/adaptive.rs index 6708a07..179a2fa 100644 --- a/src/crates/library/src/adaptive.rs +++ b/src/crates/library/src/adaptive.rs @@ -28,18 +28,22 @@ macro_rules! get_inner { impl, HI: Default + Container, E> Container for AdaptiveContainer { + #[inline(always)] fn len(&self) -> usize { get_inner!(self, c, c.len()) } + #[inline(always)] fn is_empty(&self) -> bool { get_inner!(self, c, c.is_empty()) } + #[inline(always)] fn contains(&self, x: &E) -> bool { get_inner!(self, c, c.contains(x)) } + #[inline(always)] fn insert(&mut self, elt: E) { get_inner!(self, c, c.insert(elt)); if let Self::Low(l, _) = self { @@ -56,14 +60,17 @@ impl, HI: Default + Container } } + #[inline(always)] fn remove(&mut self, elt: E) -> Option { get_inner!(self, c, c.remove(elt)) } + #[inline(always)] fn clear(&mut self) { get_inner!(self, c, c.clear()) } + #[inline(always)] fn iter<'a>(&'a self) -> impl Iterator where E: 'a, @@ -81,14 +88,17 @@ where LO: Mapping, HI: Mapping, { + #[inline(always)] fn len(&self) -> usize { get_inner!(self, c, c.len()) } + #[inline(always)] fn contains(&mut self, x: &K) -> bool { get_inner!(self, c, c.contains(x)) } + #[inline(always)] fn insert(&mut self, key: K, val: V) -> Option { let res = get_inner!(self, c, c.insert(key, val)); if let Self::Low(l, _) = self { @@ -106,18 +116,22 @@ where res } + #[inline(always)] fn get(&self, key: &K) -> Option<&V> { get_inner!(self, c, c.get(key)) } + #[inline(always)] fn remove(&mut self, key: &K) -> Option { get_inner!(self, c, c.remove(key)) } + #[inline(always)] fn clear(&mut self) { *self = Self::Low(LO::default(), PhantomData); } + #[inline(always)] fn iter<'a>(&'a self) -> impl Iterator + 'a where K: 'a, -- cgit v1.2.3