Skip to content

Commit 381d683

Browse files
committed
Add missing #[inline]
1 parent cd0cf99 commit 381d683

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/map.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,7 @@ where
973973
/// so that the map now contains keys which compare equal, search may start
974974
/// acting erratically, with two keys randomly masking each other. Implementations
975975
/// are free to assume this doesn't happen (within the limits of memory-safety).
976+
#[inline]
976977
pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<K, V, S> {
977978
self.reserve(1);
978979
RawEntryBuilderMut { map: self }
@@ -993,6 +994,7 @@ where
993994
/// `get` should be preferred.
994995
///
995996
/// Immutable raw entries have very limited use; you might instead want `raw_entry_mut`.
997+
#[inline]
996998
pub fn raw_entry(&self) -> RawEntryBuilder<K, V, S> {
997999
RawEntryBuilder { map: self }
9981000
}
@@ -1283,6 +1285,7 @@ where
12831285
K: Eq + Hash,
12841286
{
12851287
/// Create a `RawEntryMut` from the given key.
1288+
#[inline]
12861289
pub fn from_key<Q: ?Sized>(self, k: &Q) -> RawEntryMut<'a, K, V, S>
12871290
where
12881291
K: Borrow<Q>,
@@ -1294,6 +1297,7 @@ where
12941297
}
12951298

12961299
/// Create a `RawEntryMut` from the given key and its hash.
1300+
#[inline]
12971301
pub fn from_key_hashed_nocheck<Q: ?Sized>(self, hash: u64, k: &Q) -> RawEntryMut<'a, K, V, S>
12981302
where
12991303
K: Borrow<Q>,
@@ -1302,6 +1306,7 @@ where
13021306
self.from_hash(hash, |q| q.borrow().eq(k))
13031307
}
13041308

1309+
#[inline]
13051310
fn search<F>(self, hash: u64, mut is_match: F) -> RawEntryMut<'a, K, V, S>
13061311
where
13071312
for<'b> F: FnMut(&'b K) -> bool,
@@ -1319,6 +1324,7 @@ where
13191324
}
13201325

13211326
/// Create a `RawEntryMut` from the given hash.
1327+
#[inline]
13221328
pub fn from_hash<F>(self, hash: u64, is_match: F) -> RawEntryMut<'a, K, V, S>
13231329
where
13241330
for<'b> F: FnMut(&'b K) -> bool,
@@ -1329,6 +1335,7 @@ where
13291335
/// Search possible locations for an element with hash `hash` until `is_match` returns true for
13301336
/// one of them. There is no guarantee that all keys passed to `is_match` will have the provided
13311337
/// hash.
1338+
#[inline]
13321339
pub fn search_bucket<F>(self, hash: u64, is_match: F) -> RawEntryMut<'a, K, V, S>
13331340
where
13341341
for<'b> F: FnMut(&'b K) -> bool,
@@ -1342,6 +1349,7 @@ where
13421349
S: BuildHasher,
13431350
{
13441351
/// Access an entry by key.
1352+
#[inline]
13451353
pub fn from_key<Q: ?Sized>(self, k: &Q) -> Option<(&'a K, &'a V)>
13461354
where
13471355
K: Borrow<Q>,
@@ -1353,6 +1361,7 @@ where
13531361
}
13541362

13551363
/// Access an entry by a key and its hash.
1364+
#[inline]
13561365
pub fn from_key_hashed_nocheck<Q: ?Sized>(self, hash: u64, k: &Q) -> Option<(&'a K, &'a V)>
13571366
where
13581367
K: Borrow<Q>,
@@ -1361,6 +1370,7 @@ where
13611370
self.from_hash(hash, |q| q.borrow().eq(k))
13621371
}
13631372

1373+
#[inline]
13641374
fn search<F>(self, hash: u64, mut is_match: F) -> Option<(&'a K, &'a V)>
13651375
where
13661376
F: FnMut(&K) -> bool,
@@ -1375,6 +1385,7 @@ where
13751385
}
13761386

13771387
/// Access an entry by hash.
1388+
#[inline]
13781389
pub fn from_hash<F>(self, hash: u64, is_match: F) -> Option<(&'a K, &'a V)>
13791390
where
13801391
F: FnMut(&K) -> bool,
@@ -1385,6 +1396,7 @@ where
13851396
/// Search possible locations for an element with hash `hash` until `is_match` returns true for
13861397
/// one of them. There is no guarantee that all keys passed to `is_match` will have the provided
13871398
/// hash.
1399+
#[inline]
13881400
pub fn search_bucket<F>(self, hash: u64, is_match: F) -> Option<(&'a K, &'a V)>
13891401
where
13901402
F: FnMut(&K) -> bool,
@@ -1410,6 +1422,7 @@ impl<'a, K, V, S> RawEntryMut<'a, K, V, S> {
14101422
/// *map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 10).1 *= 2;
14111423
/// assert_eq!(map["poneyland"], 6);
14121424
/// ```
1425+
#[inline]
14131426
pub fn or_insert(self, default_key: K, default_val: V) -> (&'a mut K, &'a mut V)
14141427
where
14151428
K: Hash,
@@ -1437,6 +1450,7 @@ impl<'a, K, V, S> RawEntryMut<'a, K, V, S> {
14371450
///
14381451
/// assert_eq!(map["poneyland"], "hoho".to_string());
14391452
/// ```
1453+
#[inline]
14401454
pub fn or_insert_with<F>(self, default: F) -> (&'a mut K, &'a mut V)
14411455
where
14421456
F: FnOnce() -> (K, V),
@@ -1474,6 +1488,7 @@ impl<'a, K, V, S> RawEntryMut<'a, K, V, S> {
14741488
/// .or_insert("poneyland", 0);
14751489
/// assert_eq!(map["poneyland"], 43);
14761490
/// ```
1491+
#[inline]
14771492
pub fn and_modify<F>(self, f: F) -> Self
14781493
where
14791494
F: FnOnce(&mut K, &mut V),
@@ -1493,38 +1508,45 @@ impl<'a, K, V, S> RawEntryMut<'a, K, V, S> {
14931508

14941509
impl<'a, K, V> RawOccupiedEntryMut<'a, K, V> {
14951510
/// Gets a reference to the key in the entry.
1511+
#[inline]
14961512
pub fn key(&self) -> &K {
14971513
unsafe { &self.elem.as_ref().0 }
14981514
}
14991515

15001516
/// Gets a mutable reference to the key in the entry.
1517+
#[inline]
15011518
pub fn key_mut(&mut self) -> &mut K {
15021519
unsafe { &mut self.elem.as_mut().0 }
15031520
}
15041521

15051522
/// Converts the entry into a mutable reference to the key in the entry
15061523
/// with a lifetime bound to the map itself.
1524+
#[inline]
15071525
pub fn into_key(self) -> &'a mut K {
15081526
unsafe { &mut self.elem.as_mut().0 }
15091527
}
15101528

15111529
/// Gets a reference to the value in the entry.
1530+
#[inline]
15121531
pub fn get(&self) -> &V {
15131532
unsafe { &self.elem.as_ref().1 }
15141533
}
15151534

15161535
/// Converts the OccupiedEntry into a mutable reference to the value in the entry
15171536
/// with a lifetime bound to the map itself.
1537+
#[inline]
15181538
pub fn into_mut(self) -> &'a mut V {
15191539
unsafe { &mut self.elem.as_mut().1 }
15201540
}
15211541

15221542
/// Gets a mutable reference to the value in the entry.
1543+
#[inline]
15231544
pub fn get_mut(&mut self) -> &mut V {
15241545
unsafe { &mut self.elem.as_mut().1 }
15251546
}
15261547

15271548
/// Gets a reference to the key and value in the entry.
1549+
#[inline]
15281550
pub fn get_key_value(&mut self) -> (&K, &V) {
15291551
unsafe {
15301552
let &(ref key, ref value) = self.elem.as_ref();
@@ -1533,6 +1555,7 @@ impl<'a, K, V> RawOccupiedEntryMut<'a, K, V> {
15331555
}
15341556

15351557
/// Gets a mutable reference to the key and value in the entry.
1558+
#[inline]
15361559
pub fn get_key_value_mut(&mut self) -> (&mut K, &mut V) {
15371560
unsafe {
15381561
let &mut (ref mut key, ref mut value) = self.elem.as_mut();
@@ -1542,6 +1565,7 @@ impl<'a, K, V> RawOccupiedEntryMut<'a, K, V> {
15421565

15431566
/// Converts the OccupiedEntry into a mutable reference to the key and value in the entry
15441567
/// with a lifetime bound to the map itself.
1568+
#[inline]
15451569
pub fn into_key_value(self) -> (&'a mut K, &'a mut V) {
15461570
unsafe {
15471571
let &mut (ref mut key, ref mut value) = self.elem.as_mut();
@@ -1550,21 +1574,25 @@ impl<'a, K, V> RawOccupiedEntryMut<'a, K, V> {
15501574
}
15511575

15521576
/// Sets the value of the entry, and returns the entry's old value.
1577+
#[inline]
15531578
pub fn insert(&mut self, value: V) -> V {
15541579
mem::replace(self.get_mut(), value)
15551580
}
15561581

15571582
/// Sets the value of the entry, and returns the entry's old value.
1583+
#[inline]
15581584
pub fn insert_key(&mut self, key: K) -> K {
15591585
mem::replace(self.key_mut(), key)
15601586
}
15611587

15621588
/// Takes the value out of the entry, and returns it.
1589+
#[inline]
15631590
pub fn remove(self) -> V {
15641591
self.remove_entry().1
15651592
}
15661593

15671594
/// Take the ownership of the key and value from the map.
1595+
#[inline]
15681596
pub fn remove_entry(self) -> (K, V) {
15691597
unsafe {
15701598
self.table.erase_no_drop(&self.elem);
@@ -1576,6 +1604,7 @@ impl<'a, K, V> RawOccupiedEntryMut<'a, K, V> {
15761604
impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> {
15771605
/// Sets the value of the entry with the VacantEntry's key,
15781606
/// and returns a mutable reference to it.
1607+
#[inline]
15791608
pub fn insert(self, key: K, value: V) -> (&'a mut K, &'a mut V)
15801609
where
15811610
K: Hash,
@@ -1588,6 +1617,7 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> {
15881617

15891618
/// Sets the value of the entry with the VacantEntry's key,
15901619
/// and returns a mutable reference to it.
1620+
#[inline]
15911621
pub fn insert_hashed_nocheck(self, hash: u64, key: K, value: V) -> (&'a mut K, &'a mut V)
15921622
where
15931623
K: Hash,

src/set.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ where
820820
T: Eq + Hash,
821821
S: BuildHasher + Default,
822822
{
823+
#[inline]
823824
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> HashSet<T, S> {
824825
let mut set = HashSet::with_hasher(Default::default());
825826
set.extend(iter);

0 commit comments

Comments
 (0)