summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2023-07-09 15:37:51 -0700
committerWilfred Hughes <me@wilfred.me.uk>2023-07-09 15:37:51 -0700
commitd9911e0b49c030d3b84fec36c3fa8a25317a5398 (patch)
tree56ed4c8b61c15b1516ed6039baa8ccf2f5b945d1
parentf2456a12b272d22530785b0bc1162d6583a91ac0 (diff)
Move DftHashMap to a separate file
-rw-r--r--src/diff/dijkstra.rs3
-rw-r--r--src/diff/graph.rs13
-rw-r--r--src/hash.rs12
-rw-r--r--src/main.rs1
4 files changed, 17 insertions, 12 deletions
diff --git a/src/diff/dijkstra.rs b/src/diff/dijkstra.rs
index 2f80946a82..37145a2fe1 100644
--- a/src/diff/dijkstra.rs
+++ b/src/diff/dijkstra.rs
@@ -5,7 +5,8 @@ use std::{cmp::Reverse, env};
use crate::{
diff::changes::ChangeMap,
- diff::graph::{populate_change_map, set_neighbours, DftHashMap, Edge, Vertex},
+ diff::graph::{populate_change_map, set_neighbours, Edge, Vertex},
+ hash::DftHashMap,
parse::syntax::Syntax,
};
use bumpalo::Bump;
diff --git a/src/diff/graph.rs b/src/diff/graph.rs
index 9507dd3c69..7703bc1a54 100644
--- a/src/diff/graph.rs
+++ b/src/diff/graph.rs
@@ -1,12 +1,11 @@
//! A graph representation for computing tree diffs.
use bumpalo::Bump;
-use rustc_hash::FxHasher;
use std::{
cell::{Cell, RefCell},
cmp::min,
fmt,
- hash::{BuildHasherDefault, Hash, Hasher},
+ hash::{Hash, Hasher},
};
use strsim::normalized_levenshtein;
@@ -15,6 +14,7 @@ use crate::{
changes::{insert_deep_unchanged, ChangeKind, ChangeMap},
stack::Stack,
},
+ hash::DftHashMap,
parse::syntax::{AtomKind, Syntax, SyntaxId},
};
use Edge::*;
@@ -343,15 +343,6 @@ impl Edge {
}
}
-/// A fast hashmap with no hash DoS protection. This is used in
-/// extremely hot code.
-///
-/// Wrapping FxHasher (the fastest hash algorithm in difftastic
-/// benchmarks) in a hashborwn::HashMap rather than std HashMap is a
-/// little faster, and it also allows us to use the entry_ref API
-/// which is unavailable in stable Rust.
-pub type DftHashMap<K, V> = hashbrown::HashMap<K, V, BuildHasherDefault<FxHasher>>;
-
fn allocate_if_new<'s, 'b>(
v: Vertex<'s, 'b>,
alloc: &'b Bump,
diff --git a/src/hash.rs b/src/hash.rs
new file mode 100644
index 0000000000..0edc099073
--- /dev/null
+++ b/src/hash.rs
@@ -0,0 +1,12 @@
+use std::hash::BuildHasherDefault;
+
+use rustc_hash::FxHasher;
+
+/// A fast hashmap with no hash DoS protection. This is used in
+/// extremely hot code.
+///
+/// Wrapping FxHasher (the fastest hash algorithm in difftastic
+/// benchmarks) in a hashbrown::HashMap rather than std HashMap is a
+/// little faster, and it also allows us to use the entry_ref API
+/// which is unavailable in stable Rust.
+pub type DftHashMap<K, V> = hashbrown::HashMap<K, V, BuildHasherDefault<FxHasher>>;
diff --git a/src/main.rs b/src/main.rs
index 4588c94b04..efc4981a0e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -28,6 +28,7 @@ mod diff;
mod display;
mod exit_codes;
mod files;
+mod hash;
mod line_parser;
mod lines;
mod options;