Lrc -> Rc
This commit is contained in:
parent
597c6514d1
commit
07266362c6
2 changed files with 13 additions and 12 deletions
|
@ -41,7 +41,7 @@ impl ReverseSccGraph {
|
||||||
impl RegionInferenceContext<'_> {
|
impl RegionInferenceContext<'_> {
|
||||||
/// Compute the reverse SCC-based constraint graph (lazily).
|
/// Compute the reverse SCC-based constraint graph (lazily).
|
||||||
pub(super) fn compute_reverse_scc_graph(&mut self) {
|
pub(super) fn compute_reverse_scc_graph(&mut self) {
|
||||||
if matches!(self.rev_scc_graph, Some(_)) {
|
if self.rev_scc_graph.is_some() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ use rustc_span::Span;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
/// A unit within a matcher that a `MatcherPos` can refer to. Similar to (and derived from)
|
/// A unit within a matcher that a `MatcherPos` can refer to. Similar to (and derived from)
|
||||||
/// `mbe::TokenTree`, but designed specifically for fast and easy traversal during matching.
|
/// `mbe::TokenTree`, but designed specifically for fast and easy traversal during matching.
|
||||||
|
@ -257,10 +258,10 @@ struct MatcherPos {
|
||||||
/// against the relevant metavar by the black box parser. An element will be a `MatchedSeq` if
|
/// against the relevant metavar by the black box parser. An element will be a `MatchedSeq` if
|
||||||
/// the corresponding metavar decl is within a sequence.
|
/// the corresponding metavar decl is within a sequence.
|
||||||
///
|
///
|
||||||
/// It is critical to performance that this is an `Lrc`, because it gets cloned frequently when
|
/// It is critical to performance that this is an `Rc`, because it gets cloned frequently when
|
||||||
/// processing sequences. Mostly for sequence-ending possibilities that must be tried but end
|
/// processing sequences. Mostly for sequence-ending possibilities that must be tried but end
|
||||||
/// up failing.
|
/// up failing.
|
||||||
matches: Lrc<Vec<NamedMatch>>,
|
matches: Rc<Vec<NamedMatch>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
|
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||||
|
@ -272,7 +273,7 @@ impl MatcherPos {
|
||||||
/// and both are hot enough to be always worth inlining.
|
/// and both are hot enough to be always worth inlining.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn push_match(&mut self, metavar_idx: usize, seq_depth: usize, m: NamedMatch) {
|
fn push_match(&mut self, metavar_idx: usize, seq_depth: usize, m: NamedMatch) {
|
||||||
let matches = Lrc::make_mut(&mut self.matches);
|
let matches = Rc::make_mut(&mut self.matches);
|
||||||
match seq_depth {
|
match seq_depth {
|
||||||
0 => {
|
0 => {
|
||||||
// We are not within a sequence. Just append `m`.
|
// We are not within a sequence. Just append `m`.
|
||||||
|
@ -427,7 +428,7 @@ pub struct TtParser {
|
||||||
|
|
||||||
/// Pre-allocate an empty match array, so it can be cloned cheaply for macros with many rules
|
/// Pre-allocate an empty match array, so it can be cloned cheaply for macros with many rules
|
||||||
/// that have no metavars.
|
/// that have no metavars.
|
||||||
empty_matches: Lrc<Vec<NamedMatch>>,
|
empty_matches: Rc<Vec<NamedMatch>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TtParser {
|
impl TtParser {
|
||||||
|
@ -437,7 +438,7 @@ impl TtParser {
|
||||||
cur_mps: vec![],
|
cur_mps: vec![],
|
||||||
next_mps: vec![],
|
next_mps: vec![],
|
||||||
bb_mps: vec![],
|
bb_mps: vec![],
|
||||||
empty_matches: Lrc::new(vec![]),
|
empty_matches: Rc::new(vec![]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +508,7 @@ impl TtParser {
|
||||||
// Try zero matches of this sequence, by skipping over it.
|
// Try zero matches of this sequence, by skipping over it.
|
||||||
self.cur_mps.push(MatcherPos {
|
self.cur_mps.push(MatcherPos {
|
||||||
idx: idx_first_after,
|
idx: idx_first_after,
|
||||||
matches: Lrc::clone(&mp.matches),
|
matches: Rc::clone(&mp.matches),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,7 +522,7 @@ impl TtParser {
|
||||||
// processed next time around the loop.
|
// processed next time around the loop.
|
||||||
let ending_mp = MatcherPos {
|
let ending_mp = MatcherPos {
|
||||||
idx: mp.idx + 1, // +1 skips the Kleene op
|
idx: mp.idx + 1, // +1 skips the Kleene op
|
||||||
matches: Lrc::clone(&mp.matches),
|
matches: Rc::clone(&mp.matches),
|
||||||
};
|
};
|
||||||
self.cur_mps.push(ending_mp);
|
self.cur_mps.push(ending_mp);
|
||||||
|
|
||||||
|
@ -537,7 +538,7 @@ impl TtParser {
|
||||||
// will fail quietly when it is processed next time around the loop.
|
// will fail quietly when it is processed next time around the loop.
|
||||||
let ending_mp = MatcherPos {
|
let ending_mp = MatcherPos {
|
||||||
idx: mp.idx + 2, // +2 skips the separator and the Kleene op
|
idx: mp.idx + 2, // +2 skips the separator and the Kleene op
|
||||||
matches: Lrc::clone(&mp.matches),
|
matches: Rc::clone(&mp.matches),
|
||||||
};
|
};
|
||||||
self.cur_mps.push(ending_mp);
|
self.cur_mps.push(ending_mp);
|
||||||
|
|
||||||
|
@ -587,9 +588,9 @@ impl TtParser {
|
||||||
if *token == token::Eof {
|
if *token == token::Eof {
|
||||||
Some(match eof_mps {
|
Some(match eof_mps {
|
||||||
EofMatcherPositions::One(mut eof_mp) => {
|
EofMatcherPositions::One(mut eof_mp) => {
|
||||||
// Need to take ownership of the matches from within the `Lrc`.
|
// Need to take ownership of the matches from within the `Rc`.
|
||||||
Lrc::make_mut(&mut eof_mp.matches);
|
Rc::make_mut(&mut eof_mp.matches);
|
||||||
let matches = Lrc::try_unwrap(eof_mp.matches).unwrap().into_iter();
|
let matches = Rc::try_unwrap(eof_mp.matches).unwrap().into_iter();
|
||||||
self.nameize(matcher, matches)
|
self.nameize(matcher, matches)
|
||||||
}
|
}
|
||||||
EofMatcherPositions::Multiple => {
|
EofMatcherPositions::Multiple => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue