1
Fork 0

safe transmute: use FxIndex{Map,Set} instead of FxHash{Map,Set}

resolves query instability issues, and probably better for performance
This commit is contained in:
Jack Wrenn 2022-08-23 15:52:49 +00:00
parent f46fffc276
commit 1d844fe629
4 changed files with 2 additions and 14 deletions

View file

@ -104,7 +104,6 @@ where
}
#[instrument(level = "debug")]
#[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))]
pub(crate) fn from_nfa(nfa: Nfa<R>) -> Self {
let Nfa { transitions: nfa_transitions, start: nfa_start, accepting: nfa_accepting } = nfa;

View file

@ -119,8 +119,6 @@ where
let mut transitions: Map<State, Map<Transition<R>, Set<State>>> = self.transitions;
// the iteration order doesn't matter
#[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))]
for (source, transition) in other.transitions {
let fix_state = |state| if state == other.start { self.accepting } else { state };
let entry = transitions.entry(fix_state(source)).or_default();
@ -142,8 +140,6 @@ where
let mut transitions: Map<State, Map<Transition<R>, Set<State>>> = self.transitions.clone();
// the iteration order doesn't matter
#[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))]
for (&(mut source), transition) in other.transitions.iter() {
// if source is starting state of `other`, replace with starting state of `self`
if source == other.start {
@ -152,8 +148,6 @@ where
let entry = transitions.entry(source).or_default();
for (edge, destinations) in transition {
let entry = entry.entry(edge.clone()).or_default();
// the iteration order doesn't matter
#[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))]
for &(mut destination) in destinations {
// if dest is accepting state of `other`, replace with accepting state of `self`
if destination == other.accepting {