mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-30 03:57:37 +00:00
Add #[inline]
declarations
This commit is contained in:
parent
8287842eb4
commit
2ff1fc9b81
@ -68,6 +68,7 @@ macro_rules! encoder_methods {
|
||||
impl<'tcx> Encoder for EncodeContext<'tcx> {
|
||||
type Error = <opaque::Encoder as Encoder>::Error;
|
||||
|
||||
#[inline]
|
||||
fn emit_unit(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
@ -381,15 +381,18 @@ impl<'tcx> Body<'tcx> {
|
||||
}
|
||||
|
||||
/// Returns the return type; it always return first element from `local_decls` array.
|
||||
#[inline]
|
||||
pub fn return_ty(&self) -> Ty<'tcx> {
|
||||
self.local_decls[RETURN_PLACE].ty
|
||||
}
|
||||
|
||||
/// Gets the location of the terminator for the given block.
|
||||
#[inline]
|
||||
pub fn terminator_loc(&self, bb: BasicBlock) -> Location {
|
||||
Location { block: bb, statement_index: self[bb].statements.len() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn predecessors_for(
|
||||
&self,
|
||||
bb: BasicBlock,
|
||||
@ -398,6 +401,7 @@ impl<'tcx> Body<'tcx> {
|
||||
MappedLockGuard::map(predecessors, |preds| &mut preds[bb])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn predecessors(&self) -> impl std::ops::Deref<Target = Predecessors> + '_ {
|
||||
self.predecessor_cache.compute(&self.basic_blocks)
|
||||
}
|
||||
@ -2639,18 +2643,21 @@ impl<'tcx> graph::DirectedGraph for Body<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> graph::WithNumNodes for Body<'tcx> {
|
||||
#[inline]
|
||||
fn num_nodes(&self) -> usize {
|
||||
self.basic_blocks.len()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> graph::WithStartNode for Body<'tcx> {
|
||||
#[inline]
|
||||
fn start_node(&self) -> Self::Node {
|
||||
START_BLOCK
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> graph::WithSuccessors for Body<'tcx> {
|
||||
#[inline]
|
||||
fn successors(&self, node: Self::Node) -> <Self as GraphSuccessors<'_>>::Iter {
|
||||
self.basic_blocks[node].terminator().successors().cloned()
|
||||
}
|
||||
@ -2667,6 +2674,7 @@ impl graph::GraphPredecessors<'graph> for Body<'tcx> {
|
||||
}
|
||||
|
||||
impl graph::WithPredecessors for Body<'tcx> {
|
||||
#[inline]
|
||||
fn predecessors(&self, node: Self::Node) -> <Self as graph::GraphPredecessors<'_>>::Iter {
|
||||
self.predecessors_for(node).clone().into_iter()
|
||||
}
|
||||
|
@ -15,14 +15,17 @@ pub struct PredecessorCache {
|
||||
}
|
||||
|
||||
impl PredecessorCache {
|
||||
#[inline]
|
||||
pub fn new() -> Self {
|
||||
PredecessorCache { cache: Lock::new(None) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn invalidate(&mut self) {
|
||||
*self.cache.get_mut() = None;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn compute(
|
||||
&self,
|
||||
basic_blocks: &IndexVec<BasicBlock, BasicBlockData<'_>>,
|
||||
@ -45,18 +48,21 @@ impl PredecessorCache {
|
||||
}
|
||||
|
||||
impl serialize::Encodable for PredecessorCache {
|
||||
#[inline]
|
||||
fn encode<S: serialize::Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
serialize::Encodable::encode(&(), s)
|
||||
}
|
||||
}
|
||||
|
||||
impl serialize::Decodable for PredecessorCache {
|
||||
#[inline]
|
||||
fn decode<D: serialize::Decoder>(d: &mut D) -> Result<Self, D::Error> {
|
||||
serialize::Decodable::decode(d).map(|_v: ()| Self::new())
|
||||
}
|
||||
}
|
||||
|
||||
impl<CTX> HashStable<CTX> for PredecessorCache {
|
||||
#[inline]
|
||||
fn hash_stable(&self, _: &mut CTX, _: &mut StableHasher) {
|
||||
// do nothing
|
||||
}
|
||||
|
@ -922,6 +922,7 @@ where
|
||||
{
|
||||
type Error = E::Error;
|
||||
|
||||
#[inline]
|
||||
fn emit_unit(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user