Skip to content

Commit 946ea14

Browse files
committed
Inline things
1 parent e955dbc commit 946ea14

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

src/libarena/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ pub struct DroplessArena {
298298
unsafe impl Send for DroplessArena {}
299299

300300
impl Default for DroplessArena {
301+
#[inline]
301302
fn default() -> DroplessArena {
302303
DroplessArena {
303304
ptr: Cell::new(0 as *mut u8),
@@ -319,6 +320,7 @@ impl DroplessArena {
319320
false
320321
}
321322

323+
#[inline]
322324
fn align(&self, align: usize) {
323325
let final_address = ((self.ptr.get() as usize) + align - 1) & !(align - 1);
324326
self.ptr.set(final_address as *mut u8);

src/libcore/num/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3614,6 +3614,7 @@ assert_eq!(3", stringify!($SelfT), ".checked_next_power_of_two(), Some(4));
36143614
assert_eq!(", stringify!($SelfT), "::max_value().checked_next_power_of_two(), None);",
36153615
$EndFeature, "
36163616
```"),
3617+
#[inline]
36173618
#[stable(feature = "rust1", since = "1.0.0")]
36183619
pub fn checked_next_power_of_two(self) -> Option<Self> {
36193620
self.one_less_than_next_power_of_two().checked_add(1)

src/libstd/collections/hash/map.rs

+7
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ impl<K, V, S> HashMap<K, V, S>
849849
/// let mut map: HashMap<&str, i32> = HashMap::new();
850850
/// map.reserve(10);
851851
/// ```
852+
#[inline]
852853
#[stable(feature = "rust1", since = "1.0.0")]
853854
pub fn reserve(&mut self, additional: usize) {
854855
match self.reserve_internal(additional, Infallible) {
@@ -880,6 +881,7 @@ impl<K, V, S> HashMap<K, V, S>
880881
self.reserve_internal(additional, Fallible)
881882
}
882883

884+
#[inline]
883885
fn reserve_internal(&mut self, additional: usize, fallibility: Fallibility)
884886
-> Result<(), CollectionAllocErr> {
885887

@@ -1571,6 +1573,7 @@ impl<K, V, S> HashMap<K, V, S>
15711573
/// so that the map now contains keys which compare equal, search may start
15721574
/// acting erratically, with two keys randomly masking each other. Implementations
15731575
/// are free to assume this doesn't happen (within the limits of memory-safety).
1576+
#[inline(always)]
15741577
#[unstable(feature = "hash_raw_entry", issue = "56167")]
15751578
pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<K, V, S> {
15761579
self.reserve(1);
@@ -1911,6 +1914,7 @@ impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S>
19111914
}
19121915

19131916
/// Create a `RawEntryMut` from the given key and its hash.
1917+
#[inline]
19141918
#[unstable(feature = "hash_raw_entry", issue = "56167")]
19151919
pub fn from_key_hashed_nocheck<Q: ?Sized>(self, hash: u64, k: &Q) -> RawEntryMut<'a, K, V, S>
19161920
where K: Borrow<Q>,
@@ -1919,6 +1923,7 @@ impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S>
19191923
self.from_hash(hash, |q| q.borrow().eq(k))
19201924
}
19211925

1926+
#[inline]
19221927
fn search<F>(self, hash: u64, is_match: F, compare_hashes: bool) -> RawEntryMut<'a, K, V, S>
19231928
where for<'b> F: FnMut(&'b K) -> bool,
19241929
{
@@ -1941,6 +1946,7 @@ impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S>
19411946
}
19421947
}
19431948
/// Create a `RawEntryMut` from the given hash.
1949+
#[inline]
19441950
#[unstable(feature = "hash_raw_entry", issue = "56167")]
19451951
pub fn from_hash<F>(self, hash: u64, is_match: F) -> RawEntryMut<'a, K, V, S>
19461952
where for<'b> F: FnMut(&'b K) -> bool,
@@ -2215,6 +2221,7 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> {
22152221

22162222
/// Sets the value of the entry with the VacantEntry's key,
22172223
/// and returns a mutable reference to it.
2224+
#[inline]
22182225
#[unstable(feature = "hash_raw_entry", issue = "56167")]
22192226
pub fn insert_hashed_nocheck(self, hash: u64, key: K, value: V) -> (&'a mut K, &'a mut V) {
22202227
let hash = SafeHash::new(hash);

src/libstd/collections/hash/table.rs

+4
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ impl<K, V, M> Put<K, V> for FullBucket<K, V, M>
329329
}
330330

331331
impl<K, V, M: Deref<Target = RawTable<K, V>>> Bucket<K, V, M> {
332+
#[inline]
332333
pub fn new(table: M, hash: SafeHash) -> Bucket<K, V, M> {
333334
Bucket::at_index(table, hash.inspect() as usize)
334335
}
@@ -342,6 +343,7 @@ impl<K, V, M: Deref<Target = RawTable<K, V>>> Bucket<K, V, M> {
342343
}
343344
}
344345

346+
#[inline]
345347
pub fn at_index(table: M, ib_index: usize) -> Bucket<K, V, M> {
346348
// if capacity is 0, then the RawBucket will be populated with bogus pointers.
347349
// This is an uncommon case though, so avoid it in release builds.
@@ -654,6 +656,7 @@ impl<K, V, M> GapThenFull<K, V, M>
654656

655657
// Returns a Layout which describes the allocation required for a hash table,
656658
// and the offset of the array of (key, value) pairs in the allocation.
659+
#[inline(always)]
657660
fn calculate_layout<K, V>(capacity: usize) -> Result<(Layout, usize), LayoutErr> {
658661
let hashes = Layout::array::<HashUint>(capacity)?;
659662
let pairs = Layout::array::<(K, V)>(capacity)?;
@@ -722,6 +725,7 @@ impl<K, V> RawTable<K, V> {
722725
}
723726
}
724727

728+
#[inline(always)]
725729
fn raw_bucket_at(&self, index: usize) -> RawBucket<K, V> {
726730
let (_, pairs_offset) = calculate_layout::<K, V>(self.capacity())
727731
.unwrap_or_else(|_| unsafe { hint::unreachable_unchecked() });

0 commit comments

Comments
 (0)