diff --git a/src/lib.rs b/src/lib.rs index 838f05d..188e740 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,7 @@ pub struct DefaultHashBuilder(hashbrown::DefaultHashBuilder); impl BuildHasher for DefaultHashBuilder { type Hasher = DefaultHasher; - #[inline] + #[inline(always)] fn build_hasher(&self) -> Self::Hasher { DefaultHasher(self.0.build_hasher()) } @@ -33,73 +33,73 @@ impl BuildHasher for DefaultHashBuilder { pub struct DefaultHasher(::Hasher); impl Hasher for DefaultHasher { - #[inline] + #[inline(always)] fn write(&mut self, bytes: &[u8]) { self.0.write(bytes) } - #[inline] + #[inline(always)] fn write_u8(&mut self, i: u8) { self.0.write_u8(i) } - #[inline] + #[inline(always)] fn write_u16(&mut self, i: u16) { self.0.write_u16(i) } - #[inline] + #[inline(always)] fn write_u32(&mut self, i: u32) { self.0.write_u32(i) } - #[inline] + #[inline(always)] fn write_u64(&mut self, i: u64) { self.0.write_u64(i) } - #[inline] + #[inline(always)] fn write_u128(&mut self, i: u128) { self.0.write_u128(i) } - #[inline] + #[inline(always)] fn write_usize(&mut self, i: usize) { self.0.write_usize(i) } - #[inline] - fn finish(&self) -> u64 { - self.0.finish() - } - - #[inline] + #[inline(always)] fn write_i8(&mut self, i: i8) { self.0.write_i8(i) } - #[inline] + #[inline(always)] fn write_i16(&mut self, i: i16) { self.0.write_i16(i) } - #[inline] + #[inline(always)] fn write_i32(&mut self, i: i32) { self.0.write_i32(i) } - #[inline] + #[inline(always)] fn write_i64(&mut self, i: i64) { self.0.write_i64(i) } - #[inline] + #[inline(always)] fn write_i128(&mut self, i: i128) { self.0.write_i128(i) } - #[inline] + #[inline(always)] fn write_isize(&mut self, i: isize) { self.0.write_isize(i) } + + #[inline(always)] + fn finish(&self) -> u64 { + self.0.finish() + } } diff --git a/src/linked_hash_map.rs b/src/linked_hash_map.rs index 6ba6478..10f5d70 100644 --- a/src/linked_hash_map.rs +++ b/src/linked_hash_map.rs @@ -51,7 +51,6 @@ pub struct LinkedHashMap { } impl LinkedHashMap { - #[inline] pub fn new() -> Self { Self { hash_builder: DefaultHashBuilder::default(), @@ -61,7 +60,6 @@ impl LinkedHashMap { } } - #[inline] pub fn with_capacity(capacity: usize) -> Self { Self { hash_builder: DefaultHashBuilder::default(), @@ -73,7 +71,6 @@ impl LinkedHashMap { } impl LinkedHashMap { - #[inline] pub fn with_hasher(hash_builder: S) -> Self { Self { hash_builder, @@ -83,7 +80,6 @@ impl LinkedHashMap { } } - #[inline] pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self { Self { hash_builder, @@ -100,10 +96,9 @@ impl LinkedHashMap { #[inline] pub fn is_empty(&self) -> bool { - self.len() == 0 + self.table.is_empty() } - #[inline] pub fn clear(&mut self) { self.table.clear(); if let Some(mut values) = self.values { @@ -117,7 +112,6 @@ impl LinkedHashMap { } } - #[inline] pub fn iter(&self) -> Iter { let (head, tail) = if let Some(values) = self.values { unsafe { @@ -136,7 +130,6 @@ impl LinkedHashMap { } } - #[inline] pub fn iter_mut(&mut self) -> IterMut { let (head, tail) = if let Some(values) = self.values { unsafe { @@ -155,7 +148,6 @@ impl LinkedHashMap { } } - #[inline] pub fn drain(&mut self) -> Drain<'_, K, V> { unsafe { let (head, tail) = if let Some(mut values) = self.values { @@ -182,17 +174,14 @@ impl LinkedHashMap { } } - #[inline] pub fn keys(&self) -> Keys { Keys { inner: self.iter() } } - #[inline] pub fn values(&self) -> Values { Values { inner: self.iter() } } - #[inline] pub fn values_mut(&mut self) -> ValuesMut { ValuesMut { inner: self.iter_mut(), @@ -223,7 +212,6 @@ impl LinkedHashMap { } } - #[inline] pub fn retain(&mut self, mut f: F) where F: FnMut(&K, &mut V) -> bool, @@ -441,14 +429,12 @@ where } } - #[inline] pub fn reserve(&mut self, additional: usize) { let hash_builder = &self.hash_builder; self.table .reserve(additional, move |&n| unsafe { hash_node(hash_builder, n) }); } - #[inline] pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { let hash_builder = &self.hash_builder; self.table @@ -461,7 +447,6 @@ where }) } - #[inline] pub fn shrink_to_fit(&mut self) { let hash_builder = &self.hash_builder; unsafe { @@ -559,14 +544,12 @@ impl Default for LinkedHashMap where S: Default, { - #[inline] fn default() -> Self { Self::with_hasher(S::default()) } } impl FromIterator<(K, V)> for LinkedHashMap { - #[inline] fn from_iter>(iter: I) -> Self { let iter = iter.into_iter(); let mut map = Self::with_capacity_and_hasher(iter.size_hint().0, S::default()); @@ -580,14 +563,12 @@ where K: fmt::Debug, V: fmt::Debug, { - #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_map().entries(self).finish() } } impl PartialEq for LinkedHashMap { - #[inline] fn eq(&self, other: &Self) -> bool { self.len() == other.len() && self.iter().eq(other) } @@ -598,41 +579,34 @@ impl Eq for LinkedHashMap {} impl PartialOrd for LinkedHashMap { - #[inline] fn partial_cmp(&self, other: &Self) -> Option { self.iter().partial_cmp(other) } - #[inline] fn lt(&self, other: &Self) -> bool { self.iter().lt(other) } - #[inline] fn le(&self, other: &Self) -> bool { self.iter().le(other) } - #[inline] fn ge(&self, other: &Self) -> bool { self.iter().ge(other) } - #[inline] fn gt(&self, other: &Self) -> bool { self.iter().gt(other) } } impl Ord for LinkedHashMap { - #[inline] fn cmp(&self, other: &Self) -> Ordering { self.iter().cmp(other) } } impl Hash for LinkedHashMap { - #[inline] fn hash(&self, h: &mut H) { for e in self.iter() { e.hash(h); @@ -641,7 +615,6 @@ impl Hash for LinkedHashMap { } impl Drop for LinkedHashMap { - #[inline] fn drop(&mut self) { unsafe { if let Some(values) = self.values { @@ -683,7 +656,6 @@ where } impl Clone for LinkedHashMap { - #[inline] fn clone(&self) -> Self { let mut map = Self::with_hasher(self.hash_builder.clone()); map.extend(self.iter().map(|(k, v)| (k.clone(), v.clone()))); @@ -692,7 +664,6 @@ impl Clone for LinkedHas } impl Extend<(K, V)> for LinkedHashMap { - #[inline] fn extend>(&mut self, iter: I) { for (k, v) in iter { self.insert(k, v); @@ -706,7 +677,6 @@ where V: 'a + Copy, S: BuildHasher, { - #[inline] fn extend>(&mut self, iter: I) { for (&k, &v) in iter { self.insert(k, v); @@ -720,7 +690,6 @@ pub enum Entry<'a, K, V, S> { } impl fmt::Debug for Entry<'_, K, V, S> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Entry::Vacant(ref v) => f.debug_tuple("Entry").field(v).finish(), @@ -796,7 +765,6 @@ pub struct OccupiedEntry<'a, K, V, S> { } impl fmt::Debug for OccupiedEntry<'_, K, V, S> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("OccupiedEntry") .field("key", self.key()) @@ -878,6 +846,7 @@ impl<'a, K, V, S> OccupiedEntry<'a, K, V, S> { /// entry's value with the given `value` parameter. /// /// Does *not* move the entry to the back of the internal linked list. + #[inline] pub fn replace_entry(mut self, value: V) -> (K, V) { let old_key = mem::replace(self.raw_entry.key_mut(), self.key); let old_value = mem::replace(self.raw_entry.get_mut(), value); @@ -899,7 +868,6 @@ pub struct VacantEntry<'a, K, V, S> { } impl fmt::Debug for VacantEntry<'_, K, V, S> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("VacantEntry").field(self.key()).finish() } @@ -955,7 +923,6 @@ where self.from_hash(hash, move |o| k.eq(o.borrow())) } - #[inline] pub fn from_hash( self, hash: u64, @@ -1000,7 +967,6 @@ where self.from_hash(hash, move |o| k.eq(o.borrow())) } - #[inline] pub fn from_hash( self, hash: u64, @@ -1201,7 +1167,6 @@ impl<'a, K, V, S> RawOccupiedEntryMut<'a, K, V, S> { } /// Returns a `CursorMut` over the current entry. - #[inline] pub fn cursor_mut(self) -> CursorMut<'a, K, V, S> where K: Eq + Hash, @@ -1245,7 +1210,6 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> { self.insert_with_hasher(hash, key, value, |k| hash_key(hash_builder, k)) } - #[inline] pub fn insert_with_hasher( self, hash: u64, @@ -1275,14 +1239,12 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> { } impl fmt::Debug for RawEntryBuilderMut<'_, K, V, S> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RawEntryBuilder").finish() } } impl fmt::Debug for RawEntryMut<'_, K, V, S> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { RawEntryMut::Vacant(ref v) => f.debug_tuple("RawEntry").field(v).finish(), @@ -1292,7 +1254,6 @@ impl fmt::Debug for RawEntryMut<'_, K, V, S> { } impl fmt::Debug for RawOccupiedEntryMut<'_, K, V, S> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RawOccupiedEntryMut") .field("key", self.key()) @@ -1302,14 +1263,12 @@ impl fmt::Debug for RawOccupiedEntryMut<'_, K, } impl fmt::Debug for RawVacantEntryMut<'_, K, V, S> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RawVacantEntryMut").finish() } } impl fmt::Debug for RawEntryBuilder<'_, K, V, S> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RawEntryBuilder").finish() } @@ -1378,7 +1337,6 @@ pub struct Drain<'a, K, V> { } impl IterMut<'_, K, V> { - #[inline] pub(crate) fn iter(&self) -> Iter<'_, K, V> { Iter { head: self.head.as_ptr(), @@ -1390,7 +1348,6 @@ impl IterMut<'_, K, V> { } impl IntoIter { - #[inline] pub(crate) fn iter(&self) -> Iter<'_, K, V> { Iter { head: self.head.as_ptr(), @@ -1402,7 +1359,6 @@ impl IntoIter { } impl Drain<'_, K, V> { - #[inline] pub(crate) fn iter(&self) -> Iter<'_, K, V> { Iter { head: self.head.as_ptr(), @@ -1470,14 +1426,12 @@ where } impl Clone for Iter<'_, K, V> { - #[inline] fn clone(&self) -> Self { Iter { ..*self } } } impl fmt::Debug for Iter<'_, K, V> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -1488,7 +1442,6 @@ where K: fmt::Debug, V: fmt::Debug, { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.iter()).finish() } @@ -1499,7 +1452,6 @@ where K: fmt::Debug, V: fmt::Debug, { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.iter()).finish() } @@ -1510,7 +1462,6 @@ where K: fmt::Debug, V: fmt::Debug, { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.iter()).finish() } @@ -1683,7 +1634,6 @@ impl ExactSizeIterator for IterMut<'_, K, V> {} impl ExactSizeIterator for IntoIter {} impl Drop for IntoIter { - #[inline] fn drop(&mut self) { for _ in 0..self.remaining { unsafe { @@ -1697,7 +1647,6 @@ impl Drop for IntoIter { } impl Drop for Drain<'_, K, V> { - #[inline] fn drop(&mut self) { for _ in 0..self.remaining { unsafe { @@ -1835,7 +1784,6 @@ impl CursorMut<'_, K, V, S> { } // Inserts an element immediately before the given `before` node. - #[inline] fn insert(&mut self, key: K, value: V, before: NonNull>) -> Option where K: Eq + Hash, @@ -1877,14 +1825,12 @@ pub struct Keys<'a, K, V> { } impl fmt::Debug for Keys<'_, K, V> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } impl<'a, K, V> Clone for Keys<'a, K, V> { - #[inline] fn clone(&self) -> Keys<'a, K, V> { Keys { inner: self.inner.clone(), @@ -1925,7 +1871,6 @@ pub struct Values<'a, K, V> { } impl Clone for Values<'_, K, V> { - #[inline] fn clone(&self) -> Self { Values { inner: self.inner.clone(), @@ -1934,7 +1879,6 @@ impl Clone for Values<'_, K, V> { } impl fmt::Debug for Values<'_, K, V> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -1977,7 +1921,6 @@ where K: fmt::Debug, V: fmt::Debug, { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.inner.iter()).finish() } @@ -2015,7 +1958,6 @@ impl<'a, K, V, S> IntoIterator for &'a LinkedHashMap { type Item = (&'a K, &'a V); type IntoIter = Iter<'a, K, V>; - #[inline] fn into_iter(self) -> Iter<'a, K, V> { self.iter() } @@ -2025,7 +1967,6 @@ impl<'a, K, V, S> IntoIterator for &'a mut LinkedHashMap { type Item = (&'a K, &'a mut V); type IntoIter = IterMut<'a, K, V>; - #[inline] fn into_iter(self) -> IterMut<'a, K, V> { self.iter_mut() } @@ -2035,7 +1976,6 @@ impl IntoIterator for LinkedHashMap { type Item = (K, V); type IntoIter = IntoIter; - #[inline] fn into_iter(mut self) -> IntoIter { unsafe { let (head, tail) = if let Some(values) = self.values { @@ -2073,7 +2013,6 @@ struct ValueLinks { } impl Clone for ValueLinks { - #[inline] fn clone(&self) -> Self { *self } @@ -2086,7 +2025,6 @@ struct FreeLink { } impl Clone for FreeLink { - #[inline] fn clone(&self) -> Self { *self } @@ -2149,7 +2087,9 @@ impl OptNonNullExt for Option> { // Allocate a circular list guard node if not present. #[inline] unsafe fn ensure_guard_node(head: &mut Option>>) { - if head.is_none() { + #[cold] + #[inline(never)] + unsafe fn initialize(head: &mut Option>>) { let mut p = NonNull::new_unchecked(Box::into_raw(Box::new(Node { entry: MaybeUninit::uninit(), links: Links { @@ -2162,6 +2102,10 @@ unsafe fn ensure_guard_node(head: &mut Option>>) { p.as_mut().links.value = ValueLinks { next: p, prev: p }; *head = Some(p); } + + if head.is_none() { + initialize(head); + } } // Attach the `to_attach` node to the existing circular list *before* `node`. @@ -2227,7 +2171,7 @@ unsafe fn allocate_node(free_list: &mut Option>>) -> No } // Given node is assumed to be the guard node and is *not* dropped. -#[inline] +#[inline(never)] unsafe fn drop_value_nodes(guard: NonNull>) { let mut cur = guard.as_ref().links.value.prev; while cur != guard { @@ -2240,7 +2184,7 @@ unsafe fn drop_value_nodes(guard: NonNull>) { // Drops all linked free nodes starting with the given node. Free nodes are only non-circular // singly linked, and should have uninitialized keys / values. -#[inline] +#[inline(never)] unsafe fn drop_free_nodes(mut free: Option>>) { while let Some(some_free) = free { let next_free = some_free.as_ref().links.free.next; @@ -2292,7 +2236,6 @@ struct DropFilteredValues<'a, K, V> { } impl DropFilteredValues<'_, K, V> { - #[inline] fn drop_later(&mut self, node: NonNull>) { unsafe { detach_node(node); diff --git a/src/linked_hash_set.rs b/src/linked_hash_set.rs index ecaf9ea..bc16365 100644 --- a/src/linked_hash_set.rs +++ b/src/linked_hash_set.rs @@ -14,14 +14,12 @@ pub struct LinkedHashSet { } impl LinkedHashSet { - #[inline] pub fn new() -> LinkedHashSet { LinkedHashSet { map: LinkedHashMap::new(), } } - #[inline] pub fn with_capacity(capacity: usize) -> LinkedHashSet { LinkedHashSet { map: LinkedHashMap::with_capacity(capacity), @@ -35,7 +33,6 @@ impl LinkedHashSet { self.map.capacity() } - #[inline] pub fn iter(&self) -> Iter<'_, T> { Iter { iter: self.map.keys(), @@ -52,19 +49,16 @@ impl LinkedHashSet { self.map.is_empty() } - #[inline] pub fn drain(&mut self) -> Drain { Drain { iter: self.map.drain(), } } - #[inline] pub fn clear(&mut self) { self.map.clear() } - #[inline] pub fn retain(&mut self, mut f: F) where F: FnMut(&T) -> bool, @@ -78,14 +72,12 @@ where T: Eq + Hash, S: BuildHasher, { - #[inline] pub fn with_hasher(hasher: S) -> LinkedHashSet { LinkedHashSet { map: LinkedHashMap::with_hasher(hasher), } } - #[inline] pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> LinkedHashSet { LinkedHashSet { map: LinkedHashMap::with_capacity_and_hasher(capacity, hasher), @@ -97,22 +89,18 @@ where self.map.hasher() } - #[inline] pub fn reserve(&mut self, additional: usize) { self.map.reserve(additional) } - #[inline] pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { self.map.try_reserve(additional) } - #[inline] pub fn shrink_to_fit(&mut self) { self.map.shrink_to_fit() } - #[inline] pub fn difference<'a>(&'a self, other: &'a LinkedHashSet) -> Difference<'a, T, S> { Difference { iter: self.iter(), @@ -120,7 +108,6 @@ where } } - #[inline] pub fn symmetric_difference<'a>( &'a self, other: &'a LinkedHashSet, @@ -130,7 +117,6 @@ where } } - #[inline] pub fn intersection<'a>(&'a self, other: &'a LinkedHashSet) -> Intersection<'a, T, S> { Intersection { iter: self.iter(), @@ -138,7 +124,6 @@ where } } - #[inline] pub fn union<'a>(&'a self, other: &'a LinkedHashSet) -> Union<'a, T, S> { Union { iter: self.iter().chain(other.difference(self)), @@ -186,17 +171,14 @@ where .0 } - #[inline] pub fn is_disjoint(&self, other: &LinkedHashSet) -> bool { self.iter().all(|v| !other.contains(v)) } - #[inline] pub fn is_subset(&self, other: &LinkedHashSet) -> bool { self.iter().all(|v| other.contains(v)) } - #[inline] pub fn is_superset(&self, other: &LinkedHashSet) -> bool { other.is_subset(self) } @@ -297,7 +279,6 @@ where } } - #[inline] pub fn retain_with_order(&mut self, mut f: F) where F: FnMut(&T) -> bool, @@ -307,7 +288,6 @@ where } impl Clone for LinkedHashSet { - #[inline] fn clone(&self) -> Self { let map = self.map.clone(); Self { map } @@ -319,7 +299,6 @@ where T: Eq + Hash, S: BuildHasher, { - #[inline] fn eq(&self, other: &Self) -> bool { self.len() == other.len() && self.iter().eq(other) } @@ -330,7 +309,6 @@ where T: Eq + Hash, S: BuildHasher, { - #[inline] fn hash(&self, state: &mut H) { for e in self { e.hash(state); @@ -349,7 +327,6 @@ impl fmt::Debug for LinkedHashSet where T: fmt::Debug, { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_set().entries(self.iter()).finish() } @@ -360,7 +337,6 @@ where T: Eq + Hash, S: BuildHasher + Default, { - #[inline] fn from_iter>(iter: I) -> LinkedHashSet { let mut set = LinkedHashSet::with_hasher(Default::default()); set.extend(iter); @@ -373,7 +349,6 @@ where T: Eq + Hash, S: BuildHasher, { - #[inline] fn extend>(&mut self, iter: I) { self.map.extend(iter.into_iter().map(|k| (k, ()))); } @@ -384,7 +359,6 @@ where T: 'a + Eq + Hash + Copy, S: BuildHasher, { - #[inline] fn extend>(&mut self, iter: I) { self.extend(iter.into_iter().cloned()); } @@ -394,7 +368,6 @@ impl Default for LinkedHashSet where S: Default, { - #[inline] fn default() -> LinkedHashSet { LinkedHashSet { map: LinkedHashMap::default(), @@ -409,7 +382,6 @@ where { type Output = LinkedHashSet; - #[inline] fn bitor(self, rhs: &LinkedHashSet) -> LinkedHashSet { self.union(rhs).cloned().collect() } @@ -422,7 +394,6 @@ where { type Output = LinkedHashSet; - #[inline] fn bitand(self, rhs: &LinkedHashSet) -> LinkedHashSet { self.intersection(rhs).cloned().collect() } @@ -435,7 +406,6 @@ where { type Output = LinkedHashSet; - #[inline] fn bitxor(self, rhs: &LinkedHashSet) -> LinkedHashSet { self.symmetric_difference(rhs).cloned().collect() } @@ -448,7 +418,6 @@ where { type Output = LinkedHashSet; - #[inline] fn sub(self, rhs: &LinkedHashSet) -> LinkedHashSet { self.difference(rhs).cloned().collect() } @@ -488,7 +457,6 @@ impl<'a, T, S> IntoIterator for &'a LinkedHashSet { type Item = &'a T; type IntoIter = Iter<'a, T>; - #[inline] fn into_iter(self) -> Iter<'a, T> { self.iter() } @@ -498,7 +466,6 @@ impl IntoIterator for LinkedHashSet { type Item = T; type IntoIter = IntoIter; - #[inline] fn into_iter(self) -> IntoIter { IntoIter { iter: self.map.into_iter(), @@ -507,7 +474,6 @@ impl IntoIterator for LinkedHashSet { } impl<'a, K> Clone for Iter<'a, K> { - #[inline] fn clone(&self) -> Iter<'a, K> { Iter { iter: self.iter.clone(), @@ -538,7 +504,6 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> { } impl fmt::Debug for Iter<'_, K> { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -591,7 +556,6 @@ impl DoubleEndedIterator for Drain<'_, K> { impl ExactSizeIterator for Drain<'_, K> {} impl<'a, T, S> Clone for Intersection<'a, T, S> { - #[inline] fn clone(&self) -> Intersection<'a, T, S> { Intersection { iter: self.iter.clone(), @@ -633,14 +597,12 @@ where T: fmt::Debug + Eq + Hash, S: BuildHasher, { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } impl<'a, T, S> Clone for Difference<'a, T, S> { - #[inline] fn clone(&self) -> Difference<'a, T, S> { Difference { iter: self.iter.clone(), @@ -682,14 +644,12 @@ where T: fmt::Debug + Eq + Hash, S: BuildHasher, { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } impl<'a, T, S> Clone for SymmetricDifference<'a, T, S> { - #[inline] fn clone(&self) -> SymmetricDifference<'a, T, S> { SymmetricDifference { iter: self.iter.clone(), @@ -720,14 +680,12 @@ where T: fmt::Debug + Eq + Hash, S: BuildHasher, { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } impl<'a, T, S> Clone for Union<'a, T, S> { - #[inline] fn clone(&self) -> Union<'a, T, S> { Union { iter: self.iter.clone(), @@ -740,7 +698,6 @@ where T: fmt::Debug + Eq + Hash, S: BuildHasher, { - #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } diff --git a/src/lru_cache.rs b/src/lru_cache.rs index 33cabbb..72bcfd1 100644 --- a/src/lru_cache.rs +++ b/src/lru_cache.rs @@ -18,7 +18,6 @@ pub struct LruCache { } impl LruCache { - #[inline] pub fn new(capacity: usize) -> Self { LruCache { map: LinkedHashMap::new(), @@ -29,14 +28,12 @@ impl LruCache { /// Create a new unbounded `LruCache` that does not automatically evict entries. /// /// A simple convenience method that is equivalent to `LruCache::new(usize::MAX)` - #[inline] pub fn new_unbounded() -> Self { LruCache::new(usize::MAX) } } impl LruCache { - #[inline] pub fn with_hasher(capacity: usize, hash_builder: S) -> Self { LruCache { map: LinkedHashMap::with_hasher(hash_builder), @@ -59,27 +56,22 @@ impl LruCache { self.map.is_empty() } - #[inline] pub fn clear(&mut self) { self.map.clear(); } - #[inline] pub fn iter(&self) -> Iter { self.map.iter() } - #[inline] pub fn iter_mut(&mut self) -> IterMut { self.map.iter_mut() } - #[inline] pub fn drain(&mut self) -> Drain { self.map.drain() } - #[inline] pub fn retain(&mut self, f: F) where F: FnMut(&K, &mut V) -> bool, @@ -221,7 +213,6 @@ where /// /// If there are more entries in the `LruCache` than the new capacity will allow, they are /// removed. - #[inline] pub fn set_capacity(&mut self, capacity: usize) { for _ in capacity..self.len() { self.remove_lru(); @@ -239,7 +230,6 @@ where } impl Clone for LruCache { - #[inline] fn clone(&self) -> Self { LruCache { map: self.map.clone(), @@ -249,7 +239,6 @@ impl Clone for LruCache< } impl Extend<(K, V)> for LruCache { - #[inline] fn extend>(&mut self, iter: I) { for (k, v) in iter { self.insert(k, v); @@ -261,7 +250,6 @@ impl IntoIterator for LruCache { type Item = (K, V); type IntoIter = IntoIter; - #[inline] fn into_iter(self) -> IntoIter { self.map.into_iter() } @@ -271,7 +259,6 @@ impl<'a, K, V, S> IntoIterator for &'a LruCache { type Item = (&'a K, &'a V); type IntoIter = Iter<'a, K, V>; - #[inline] fn into_iter(self) -> Iter<'a, K, V> { self.iter() } @@ -281,7 +268,6 @@ impl<'a, K, V, S> IntoIterator for &'a mut LruCache { type Item = (&'a K, &'a mut V); type IntoIter = IterMut<'a, K, V>; - #[inline] fn into_iter(self) -> IterMut<'a, K, V> { self.iter_mut() }