mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 17:54:15 +03:00
fix(fast-graph): Use fxhash instead of ahash to make iteration order consistent (#7133)
**Description:** Some operations of `petgraph` assumes the same iteration order.
This commit is contained in:
parent
b178ff5661
commit
b13eb4c811
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -4201,9 +4201,9 @@ dependencies = [
|
||||
name = "swc_fast_graph"
|
||||
version = "0.17.40"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"indexmap",
|
||||
"petgraph",
|
||||
"rustc-hash",
|
||||
"swc_common",
|
||||
]
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
||||
description = "Faster version of petgraph"
|
||||
edition = "2021"
|
||||
include = ["Cargo.toml", "src/**/*.rs"]
|
||||
license = "Apache-2.0"
|
||||
name = "swc_fast_graph"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.17.40"
|
||||
edition = "2021"
|
||||
include = ["Cargo.toml", "src/**/*.rs"]
|
||||
license = "Apache-2.0"
|
||||
name = "swc_fast_graph"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.17.40"
|
||||
|
||||
[lib]
|
||||
bench = false
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.7.6"
|
||||
indexmap = "1.6.1"
|
||||
petgraph = "0.6"
|
||||
indexmap = "1.6.1"
|
||||
petgraph = "0.6"
|
||||
swc_common = { version = "0.29.39", path = "../swc_common" }
|
||||
rustc-hash = "1.1.0"
|
||||
|
@ -6,7 +6,7 @@
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
fmt,
|
||||
hash::{self, Hash},
|
||||
hash::{self, BuildHasherDefault, Hash},
|
||||
iter::{Cloned, DoubleEndedIterator, FromIterator},
|
||||
marker::PhantomData,
|
||||
ops::Deref,
|
||||
@ -25,8 +25,11 @@ use petgraph::{
|
||||
},
|
||||
Directed, Direction, EdgeType, Incoming, IntoWeightedEdge, Outgoing, Undirected,
|
||||
};
|
||||
use rustc_hash::FxHasher;
|
||||
use swc_common::collections::AHashSet;
|
||||
|
||||
type FxBuildHasher = BuildHasherDefault<FxHasher>;
|
||||
|
||||
/// A `GraphMap` with directed edges.
|
||||
///
|
||||
/// For example, an edge from *1* to *2* is distinct from an edge from *2* to
|
||||
@ -59,8 +62,8 @@ pub type FastDiGraphMap<N, E> = FastGraphMap<N, E, Directed>;
|
||||
/// Depends on crate feature `graphmap` (default).
|
||||
#[derive(Clone)]
|
||||
pub struct FastGraphMap<N, E, Ty> {
|
||||
nodes: IndexMap<N, Vec<(N, CompactDirection)>, ahash::RandomState>,
|
||||
edges: IndexMap<(N, N), E, ahash::RandomState>,
|
||||
nodes: IndexMap<N, Vec<(N, CompactDirection)>, FxBuildHasher>,
|
||||
edges: IndexMap<(N, N), E, FxBuildHasher>,
|
||||
ty: PhantomData<Ty>,
|
||||
}
|
||||
|
||||
@ -584,7 +587,7 @@ where
|
||||
Ty: EdgeType,
|
||||
{
|
||||
from: N,
|
||||
edges: &'a IndexMap<(N, N), E, ahash::RandomState>,
|
||||
edges: &'a IndexMap<(N, N), E, FxBuildHasher>,
|
||||
iter: Neighbors<'a, N, Ty>,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user