Skip to content

Commit 4f30a24

Browse files
committed
Inline tweaks
1 parent 6d34ec1 commit 4f30a24

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

src/librustc/ty/context.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1926,13 +1926,15 @@ pub mod tls {
19261926
/// to `value` during the call to `f`. It is restored to its previous value after.
19271927
/// This is used to set the pointer to the new ImplicitCtxt.
19281928
#[cfg(parallel_queries)]
1929+
#[inline]
19291930
fn set_tlv<F: FnOnce() -> R, R>(value: usize, f: F) -> R {
19301931
rayon_core::tlv::with(value, f)
19311932
}
19321933

19331934
/// Gets Rayon's thread local variable which is preserved for Rayon jobs.
19341935
/// This is used to get the pointer to the current ImplicitCtxt.
19351936
#[cfg(parallel_queries)]
1937+
#[inline]
19361938
fn get_tlv() -> usize {
19371939
rayon_core::tlv::get()
19381940
}
@@ -1945,6 +1947,7 @@ pub mod tls {
19451947
/// It is restored to its previous value after.
19461948
/// This is used to set the pointer to the new ImplicitCtxt.
19471949
#[cfg(not(parallel_queries))]
1950+
#[inline]
19481951
fn set_tlv<F: FnOnce() -> R, R>(value: usize, f: F) -> R {
19491952
let old = get_tlv();
19501953
let _reset = OnDrop(move || TLV.with(|tlv| tlv.set(old)));
@@ -2009,6 +2012,7 @@ pub mod tls {
20092012
}
20102013

20112014
/// Sets `context` as the new current ImplicitCtxt for the duration of the function `f`
2015+
#[inline]
20122016
pub fn enter_context<'a, 'gcx: 'tcx, 'tcx, F, R>(context: &ImplicitCtxt<'a, 'gcx, 'tcx>,
20132017
f: F) -> R
20142018
where F: FnOnce(&ImplicitCtxt<'a, 'gcx, 'tcx>) -> R
@@ -2080,6 +2084,7 @@ pub mod tls {
20802084
}
20812085

20822086
/// Allows access to the current ImplicitCtxt in a closure if one is available
2087+
#[inline]
20832088
pub fn with_context_opt<F, R>(f: F) -> R
20842089
where F: for<'a, 'gcx, 'tcx> FnOnce(Option<&ImplicitCtxt<'a, 'gcx, 'tcx>>) -> R
20852090
{
@@ -2097,6 +2102,7 @@ pub mod tls {
20972102

20982103
/// Allows access to the current ImplicitCtxt.
20992104
/// Panics if there is no ImplicitCtxt available
2105+
#[inline]
21002106
pub fn with_context<F, R>(f: F) -> R
21012107
where F: for<'a, 'gcx, 'tcx> FnOnce(&ImplicitCtxt<'a, 'gcx, 'tcx>) -> R
21022108
{
@@ -2108,6 +2114,7 @@ pub mod tls {
21082114
/// with the same 'gcx lifetime as the TyCtxt passed in.
21092115
/// This will panic if you pass it a TyCtxt which has a different global interner from
21102116
/// the current ImplicitCtxt's tcx field.
2117+
#[inline]
21112118
pub fn with_related_context<'a, 'gcx, 'tcx1, F, R>(tcx: TyCtxt<'a, 'gcx, 'tcx1>, f: F) -> R
21122119
where F: for<'b, 'tcx2> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx2>) -> R
21132120
{
@@ -2126,6 +2133,7 @@ pub mod tls {
21262133
/// is given an ImplicitCtxt with the same 'tcx and 'gcx lifetimes as the TyCtxt passed in.
21272134
/// This will panic if you pass it a TyCtxt which has a different global interner or
21282135
/// a different local interner from the current ImplicitCtxt's tcx field.
2136+
#[inline]
21292137
pub fn with_fully_related_context<'a, 'gcx, 'tcx, F, R>(tcx: TyCtxt<'a, 'gcx, 'tcx>, f: F) -> R
21302138
where F: for<'b> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx>) -> R
21312139
{
@@ -2143,6 +2151,7 @@ pub mod tls {
21432151

21442152
/// Allows access to the TyCtxt in the current ImplicitCtxt.
21452153
/// Panics if there is no ImplicitCtxt available
2154+
#[inline]
21462155
pub fn with<F, R>(f: F) -> R
21472156
where F: for<'a, 'gcx, 'tcx> FnOnce(TyCtxt<'a, 'gcx, 'tcx>) -> R
21482157
{
@@ -2151,6 +2160,7 @@ pub mod tls {
21512160

21522161
/// Allows access to the TyCtxt in the current ImplicitCtxt.
21532162
/// The closure is passed None if there is no ImplicitCtxt available
2163+
#[inline]
21542164
pub fn with_opt<F, R>(f: F) -> R
21552165
where F: for<'a, 'gcx, 'tcx> FnOnce(Option<TyCtxt<'a, 'gcx, 'tcx>>) -> R
21562166
{

src/librustc/ty/query/plumbing.rs

+3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
171171

172172
/// Completes the query by updating the query cache with the `result`,
173173
/// signals the waiter and forgets the JobOwner, so it won't poison the query
174+
#[inline(always)]
174175
pub(super) fn complete(self, result: &Q::Value, dep_node_index: DepNodeIndex) {
175176
// We can move out of `self` here because we `mem::forget` it below
176177
let key = unsafe { ptr::read(&self.key) };
@@ -227,6 +228,8 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
227228
}
228229

229230
impl<'a, 'tcx, Q: QueryDescription<'tcx>> Drop for JobOwner<'a, 'tcx, Q> {
231+
#[inline(never)]
232+
#[cold]
230233
fn drop(&mut self) {
231234
// Poison the query so jobs waiting on it panic
232235
self.cache.borrow_mut().active.insert(self.key.clone(), QueryResult::Poisoned);

src/librustc_data_structures/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,14 @@ pub struct OnDrop<F: Fn()>(pub F);
113113
impl<F: Fn()> OnDrop<F> {
114114
/// Forgets the function which prevents it from running.
115115
/// Ensure that the function owns no memory, otherwise it will be leaked.
116+
#[inline]
116117
pub fn disable(self) {
117118
std::mem::forget(self);
118119
}
119120
}
120121

121122
impl<F: Fn()> Drop for OnDrop<F> {
123+
#[inline]
122124
fn drop(&mut self) {
123125
(self.0)();
124126
}

src/libserialize/opaque.rs

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ pub struct Decoder<'a> {
172172
}
173173

174174
impl<'a> Decoder<'a> {
175+
#[inline]
175176
pub fn new(data: &'a [u8], position: usize) -> Decoder<'a> {
176177
Decoder {
177178
data,

src/libstd/collections/hash/table.rs

+3
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ impl<K, V> RawTable<K, V> {
740740
}
741741
}
742742

743+
#[inline]
743744
fn new_internal(
744745
capacity: usize,
745746
fallibility: Fallibility,
@@ -755,12 +756,14 @@ impl<K, V> RawTable<K, V> {
755756

756757
/// Tries to create a new raw table from a given capacity. If it cannot allocate,
757758
/// it returns with AllocErr.
759+
#[inline]
758760
pub fn try_new(capacity: usize) -> Result<RawTable<K, V>, CollectionAllocErr> {
759761
Self::new_internal(capacity, Fallible)
760762
}
761763

762764
/// Creates a new raw table from a given capacity. All buckets are
763765
/// initially empty.
766+
#[inline]
764767
pub fn new(capacity: usize) -> RawTable<K, V> {
765768
match Self::new_internal(capacity, Infallible) {
766769
Err(CollectionAllocErr::CapacityOverflow) => panic!("capacity overflow"),

0 commit comments

Comments
 (0)