diff --git a/Cargo.lock b/Cargo.lock index 8129936..8745bf4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -495,6 +495,12 @@ version = "0.7.4" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustdoc-types" version = "0.25.0" @@ -641,6 +647,7 @@ dependencies = [ "itertools 0.12.1", "maplit", "rayon", + "rustc-hash", "rustdoc-types", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 635d631..f596091 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ readme = "./README.md" trustfall = "0.7.1" rustdoc-types = "0.25.0" rayon = { version = "1.10.0", optional = true } +rustc-hash = { version = "2.0.0", optional = true } [features] default = [] @@ -21,6 +22,8 @@ default = [] # performance on big crates, but may impact performance on small crates and # definitely increases the memory usage rayon = ["dep:rayon"] +# Use rustc-hash::{FxHashMap, FxHashSet} internally for improved performance +rustc-hash = ["dep:rustc-hash"] [[bench]] name = "indexed_crate" diff --git a/src/visibility_tracker.rs b/src/visibility_tracker.rs index 8670905..9b102d4 100644 --- a/src/visibility_tracker.rs +++ b/src/visibility_tracker.rs @@ -1,3 +1,6 @@ +#[cfg(feature = "rustc-hash")] +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; +#[cfg(not(feature = "rustc-hash"))] use std::collections::{HashMap, HashSet}; use rustdoc_types::{Crate, GenericArgs, Id, Item, ItemEnum, TypeAlias, Visibility};