mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Miscellaneous inlining improvements
Add `#[inline]` to a few trivial non-generic methods from a perf report that otherwise wouldn't be candidates for inlining.
This commit is contained in:
parent
3e51277fe6
commit
87374de3ad
@ -165,22 +165,27 @@ impl<'a> HashStable<StableHashingContext<'a>> for AdtDefData {
|
|||||||
pub struct AdtDef<'tcx>(pub Interned<'tcx, AdtDefData>);
|
pub struct AdtDef<'tcx>(pub Interned<'tcx, AdtDefData>);
|
||||||
|
|
||||||
impl<'tcx> AdtDef<'tcx> {
|
impl<'tcx> AdtDef<'tcx> {
|
||||||
|
#[inline]
|
||||||
pub fn did(self) -> DefId {
|
pub fn did(self) -> DefId {
|
||||||
self.0.0.did
|
self.0.0.did
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn variants(self) -> &'tcx IndexVec<VariantIdx, VariantDef> {
|
pub fn variants(self) -> &'tcx IndexVec<VariantIdx, VariantDef> {
|
||||||
&self.0.0.variants
|
&self.0.0.variants
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn variant(self, idx: VariantIdx) -> &'tcx VariantDef {
|
pub fn variant(self, idx: VariantIdx) -> &'tcx VariantDef {
|
||||||
&self.0.0.variants[idx]
|
&self.0.0.variants[idx]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn flags(self) -> AdtFlags {
|
pub fn flags(self) -> AdtFlags {
|
||||||
self.0.0.flags
|
self.0.0.flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn repr(self) -> ReprOptions {
|
pub fn repr(self) -> ReprOptions {
|
||||||
self.0.0.repr
|
self.0.0.repr
|
||||||
}
|
}
|
||||||
|
@ -1126,6 +1126,7 @@ impl<'tcx> TypeVisitable<'tcx> for ty::Predicate<'tcx> {
|
|||||||
self.outer_exclusive_binder() > binder
|
self.outer_exclusive_binder() > binder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn has_type_flags(&self, flags: ty::TypeFlags) -> bool {
|
fn has_type_flags(&self, flags: ty::TypeFlags) -> bool {
|
||||||
self.flags().intersects(flags)
|
self.flags().intersects(flags)
|
||||||
}
|
}
|
||||||
|
@ -1315,6 +1315,7 @@ pub struct Region<'tcx>(pub Interned<'tcx, RegionKind<'tcx>>);
|
|||||||
impl<'tcx> Deref for Region<'tcx> {
|
impl<'tcx> Deref for Region<'tcx> {
|
||||||
type Target = RegionKind<'tcx>;
|
type Target = RegionKind<'tcx>;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn deref(&self) -> &RegionKind<'tcx> {
|
fn deref(&self) -> &RegionKind<'tcx> {
|
||||||
&self.0.0
|
&self.0.0
|
||||||
}
|
}
|
||||||
|
@ -1042,6 +1042,7 @@ impl<'tcx> Ty<'tcx> {
|
|||||||
ty
|
ty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn outer_exclusive_binder(self) -> ty::DebruijnIndex {
|
pub fn outer_exclusive_binder(self) -> ty::DebruijnIndex {
|
||||||
self.0.outer_exclusive_binder
|
self.0.outer_exclusive_binder
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ pub enum DepNodeColor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DepNodeColor {
|
impl DepNodeColor {
|
||||||
|
#[inline]
|
||||||
pub fn is_green(self) -> bool {
|
pub fn is_green(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
DepNodeColor::Red => false,
|
DepNodeColor::Red => false,
|
||||||
|
@ -84,6 +84,7 @@ pub struct QueryJob {
|
|||||||
|
|
||||||
impl QueryJob {
|
impl QueryJob {
|
||||||
/// Creates a new query job.
|
/// Creates a new query job.
|
||||||
|
#[inline]
|
||||||
pub fn new(id: QueryJobId, span: Span, parent: Option<QueryJobId>) -> Self {
|
pub fn new(id: QueryJobId, span: Span, parent: Option<QueryJobId>) -> Self {
|
||||||
QueryJob {
|
QueryJob {
|
||||||
id,
|
id,
|
||||||
@ -106,6 +107,7 @@ impl QueryJob {
|
|||||||
///
|
///
|
||||||
/// This does nothing for single threaded rustc,
|
/// This does nothing for single threaded rustc,
|
||||||
/// as there are no concurrent jobs which could be waiting on us
|
/// as there are no concurrent jobs which could be waiting on us
|
||||||
|
#[inline]
|
||||||
pub fn signal_complete(self) {
|
pub fn signal_complete(self) {
|
||||||
#[cfg(parallel_compiler)]
|
#[cfg(parallel_compiler)]
|
||||||
{
|
{
|
||||||
|
@ -81,6 +81,7 @@ pub struct QuerySideEffects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl QuerySideEffects {
|
impl QuerySideEffects {
|
||||||
|
#[inline]
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
let QuerySideEffects { diagnostics } = self;
|
let QuerySideEffects { diagnostics } = self;
|
||||||
diagnostics.is_empty()
|
diagnostics.is_empty()
|
||||||
|
@ -1603,6 +1603,7 @@ impl SourceFile {
|
|||||||
self.name.is_real()
|
self.name.is_real()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn is_imported(&self) -> bool {
|
pub fn is_imported(&self) -> bool {
|
||||||
self.src.is_none()
|
self.src.is_none()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user