[rust-compiler] Use rustc-hash FxHasher for all maps and sets (#36811)
Why
FxHasher is a simple, fast, non-cryptographic hasher. std's default (SipHash) is DoS-resistant but heavy - the compiler keys maps/sets almost entirely on small integer IDs (IdentifierId, BlockId, ScopeId, …) where that protection buys nothing. Switching gives:
- Performance - faster hashing on the hot ID-keyed maps/sets used throughout the passes.
- Slight binary size reduction - drops the heavy SipHash hasher pulled in by std's
HashMap/HashSet.
Changes
std::collections::HashMap/HashSet→rustc_hash::FxHashMap/FxHashSetindexmapIndexMap/IndexSetnow useFxBuildHasher, inlined asIndexMap<K, V, FxBuildHasher>(noFxIndexMaptype aliases)rustc-hash = "2"added to all 12 crate manifestsrustc_hash/indexmapimports consolidated into single brace imports at the top of each file
The change is serde-neutral: FxHashMap and IndexMap<_, _, FxBuildHasher> serialize to byte-identical JSON, and IndexMap keeps insertion order. cargo check, cargo fmt --check, and cargo test all pass with no warnings.
Commit 06b2a50 authored - 1 parent 53b5c3c - 89 files changed, 1036 additions & 961 deletions.
File tree
- compiler
- crates
- react_compiler_ast
- src
- react_compiler_diagnostics
- src
- react_compiler_hir
- src
- react_compiler_inference
- src
- react_compiler_lowering
- src
- react_compiler_optimization
- src
- react_compiler_reactive_scopes
- src
- react_compiler_ssa
- src
- react_compiler_typeinference
- src
- react_compiler_utils
- src
- react_compiler_validation
- src
- react_compiler
- src/entrypoint
- react_compiler_ast
- crates
Comments
No comments yet. Start the discussion.