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