Skip to content

Commit

Permalink
Change hasher
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Mar 23, 2023
1 parent 480acfc commit 9e92bd2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/swc_fast_graph/src/digraph.rs
Expand Up @@ -6,7 +6,7 @@
use std::{
cmp::Ordering,
fmt,
hash::{self, Hash},
hash::{self, BuildHasherDefault, Hash},
iter::{Cloned, DoubleEndedIterator, FromIterator},
marker::PhantomData,
ops::Deref,
Expand All @@ -27,6 +27,8 @@ use petgraph::{
};
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
Expand Down Expand Up @@ -59,8 +61,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>,
}

Expand Down Expand Up @@ -584,7 +586,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>,
}

Expand Down

0 comments on commit 9e92bd2

Please sign in to comment.