Skip to content

File tree

34 files changed

+156
-152
lines changed

34 files changed

+156
-152
lines changed
 

‎src/librustc/hir/lowering.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ use hir::GenericArg;
5050
use lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
5151
ELIDED_LIFETIMES_IN_PATHS};
5252
use middle::cstore::CrateStore;
53+
use rustc_data_structures::fx::FxHashSet;
5354
use rustc_data_structures::indexed_vec::IndexVec;
5455
use rustc_data_structures::small_vec::OneVector;
5556
use rustc_data_structures::thin_vec::ThinVec;
5657
use session::Session;
5758
use util::common::FN_OUTPUT_NAME;
5859
use util::nodemap::{DefIdMap, NodeMap};
5960

60-
use std::collections::{BTreeMap, HashSet};
61+
use std::collections::BTreeMap;
6162
use std::fmt::Debug;
6263
use std::iter;
6364
use std::mem;
@@ -1342,7 +1343,7 @@ impl<'a> LoweringContext<'a> {
13421343
exist_ty_id: NodeId,
13431344
collect_elided_lifetimes: bool,
13441345
currently_bound_lifetimes: Vec<hir::LifetimeName>,
1345-
already_defined_lifetimes: HashSet<hir::LifetimeName>,
1346+
already_defined_lifetimes: FxHashSet<hir::LifetimeName>,
13461347
output_lifetimes: Vec<hir::GenericArg>,
13471348
output_lifetime_params: Vec<hir::GenericParam>,
13481349
}
@@ -1476,7 +1477,7 @@ impl<'a> LoweringContext<'a> {
14761477
exist_ty_id,
14771478
collect_elided_lifetimes: true,
14781479
currently_bound_lifetimes: Vec::new(),
1479-
already_defined_lifetimes: HashSet::new(),
1480+
already_defined_lifetimes: FxHashSet::default(),
14801481
output_lifetimes: Vec::new(),
14811482
output_lifetime_params: Vec::new(),
14821483
};

‎src/librustc/middle/weak_lang_items.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use session::config;
1414
use middle::lang_items;
1515

16+
use rustc_data_structures::fx::FxHashSet;
1617
use rustc_target::spec::PanicStrategy;
1718
use syntax::ast;
1819
use syntax::symbol::Symbol;
@@ -23,8 +24,6 @@ use hir::intravisit;
2324
use hir;
2425
use ty::TyCtxt;
2526

26-
use std::collections::HashSet;
27-
2827
macro_rules! weak_lang_items {
2928
($($name:ident, $item:ident, $sym:ident;)*) => (
3029

@@ -101,7 +100,7 @@ fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
101100
return
102101
}
103102

104-
let mut missing = HashSet::new();
103+
let mut missing = FxHashSet::default();
105104
for &cnum in tcx.crates().iter() {
106105
for &item in tcx.missing_lang_items(cnum).iter() {
107106
missing.insert(item);

‎src/librustc/session/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ use std::collections::btree_map::Iter as BTreeMapIter;
3737
use std::collections::btree_map::Keys as BTreeMapKeysIter;
3838
use std::collections::btree_map::Values as BTreeMapValuesIter;
3939

40+
use rustc_data_structures::fx::FxHashSet;
4041
use std::{fmt, str};
4142
use std::hash::Hasher;
4243
use std::collections::hash_map::DefaultHasher;
43-
use std::collections::HashSet;
4444
use std::iter::FromIterator;
4545
use std::path::{Path, PathBuf};
4646

@@ -1373,7 +1373,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
13731373
let max_atomic_width = sess.target.target.max_atomic_width();
13741374
let atomic_cas = sess.target.target.options.atomic_cas;
13751375

1376-
let mut ret = HashSet::new();
1376+
let mut ret = FxHashSet::default();
13771377
// Target bindings.
13781378
ret.insert((Symbol::intern("target_os"), Some(Symbol::intern(os))));
13791379
if let Some(ref fam) = sess.target.target.options.target_family {

‎src/librustc/session/filesearch.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
pub use self::FileMatch::*;
1414

15+
use rustc_data_structures::fx::FxHashSet;
1516
use std::borrow::Cow;
16-
use std::collections::HashSet;
1717
use std::env;
1818
use std::fs;
1919
use std::path::{Path, PathBuf};
@@ -40,7 +40,7 @@ impl<'a> FileSearch<'a> {
4040
pub fn for_each_lib_search_path<F>(&self, mut f: F) where
4141
F: FnMut(&Path, PathKind)
4242
{
43-
let mut visited_dirs = HashSet::new();
43+
let mut visited_dirs = FxHashSet::default();
4444

4545
for (path, kind) in self.search_paths.iter(self.kind) {
4646
f(path, kind);

‎src/librustc/session/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ use jobserver::Client;
4747

4848
use std;
4949
use std::cell::{self, Cell, RefCell};
50-
use std::collections::HashMap;
5150
use std::env;
5251
use std::fmt;
5352
use std::io::Write;
@@ -122,7 +121,7 @@ pub struct Session {
122121
/// Map from imported macro spans (which consist of
123122
/// the localized span for the macro body) to the
124123
/// macro name and definition span in the source crate.
125-
pub imported_macro_spans: OneThread<RefCell<HashMap<Span, (String, Span)>>>,
124+
pub imported_macro_spans: OneThread<RefCell<FxHashMap<Span, (String, Span)>>>,
126125

127126
incr_comp_session: OneThread<RefCell<IncrCompSession>>,
128127

@@ -1129,7 +1128,7 @@ pub fn build_session_(
11291128
injected_allocator: Once::new(),
11301129
allocator_kind: Once::new(),
11311130
injected_panic_runtime: Once::new(),
1132-
imported_macro_spans: OneThread::new(RefCell::new(HashMap::new())),
1131+
imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())),
11331132
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
11341133
self_profiling: Lock::new(SelfProfiler::new()),
11351134
profile_channel: Lock::new(None),

‎src/librustc/ty/query/job.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![allow(warnings)]
1212

1313
use std::mem;
14+
use rustc_data_structures::fx::FxHashSet;
1415
use rustc_data_structures::sync::{Lock, LockGuard, Lrc, Weak};
1516
use rustc_data_structures::OnDrop;
1617
use syntax_pos::Span;
@@ -21,7 +22,7 @@ use ty::context::TyCtxt;
2122
use errors::Diagnostic;
2223
use std::process;
2324
use std::{fmt, ptr};
24-
use std::collections::HashSet;
25+
2526
#[cfg(parallel_queries)]
2627
use {
2728
rayon_core,
@@ -282,7 +283,7 @@ where
282283
fn cycle_check<'tcx>(query: Lrc<QueryJob<'tcx>>,
283284
span: Span,
284285
stack: &mut Vec<(Span, Lrc<QueryJob<'tcx>>)>,
285-
visited: &mut HashSet<*const QueryJob<'tcx>>
286+
visited: &mut FxHashSet<*const QueryJob<'tcx>>
286287
) -> Option<Option<Waiter<'tcx>>> {
287288
if visited.contains(&query.as_ptr()) {
288289
return if let Some(p) = stack.iter().position(|q| q.1.as_ptr() == query.as_ptr()) {
@@ -321,7 +322,7 @@ fn cycle_check<'tcx>(query: Lrc<QueryJob<'tcx>>,
321322
#[cfg(parallel_queries)]
322323
fn connected_to_root<'tcx>(
323324
query: Lrc<QueryJob<'tcx>>,
324-
visited: &mut HashSet<*const QueryJob<'tcx>>
325+
visited: &mut FxHashSet<*const QueryJob<'tcx>>
325326
) -> bool {
326327
// We already visited this or we're deliberately ignoring it
327328
if visited.contains(&query.as_ptr()) {
@@ -357,7 +358,7 @@ fn remove_cycle<'tcx>(
357358
wakelist: &mut Vec<Lrc<QueryWaiter<'tcx>>>,
358359
tcx: TyCtxt<'_, 'tcx, '_>
359360
) -> bool {
360-
let mut visited = HashSet::new();
361+
let mut visited = FxHashSet::default();
361362
let mut stack = Vec::new();
362363
// Look for a cycle starting with the last query in `jobs`
363364
if let Some(waiter) = cycle_check(jobs.pop().unwrap(),
@@ -389,7 +390,7 @@ fn remove_cycle<'tcx>(
389390
// connected to queries outside the cycle
390391
let entry_points: Vec<Lrc<QueryJob<'tcx>>> = stack.iter().filter_map(|query| {
391392
// Mark all the other queries in the cycle as already visited
392-
let mut visited = HashSet::from_iter(stack.iter().filter_map(|q| {
393+
let mut visited = FxHashSet::from_iter(stack.iter().filter_map(|q| {
393394
if q.1.as_ptr() != query.1.as_ptr() {
394395
Some(q.1.as_ptr())
395396
} else {

‎src/librustc/util/time_graph.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::collections::HashMap;
11+
use rustc_data_structures::fx::FxHashMap;
1212
use std::fs::File;
1313
use std::io::prelude::*;
1414
use std::marker::PhantomData;
@@ -40,7 +40,7 @@ struct PerThread {
4040

4141
#[derive(Clone)]
4242
pub struct TimeGraph {
43-
data: Arc<Mutex<HashMap<TimelineId, PerThread>>>,
43+
data: Arc<Mutex<FxHashMap<TimelineId, PerThread>>>,
4444
}
4545

4646
#[derive(Clone, Copy)]
@@ -68,7 +68,7 @@ impl Drop for RaiiToken {
6868
impl TimeGraph {
6969
pub fn new() -> TimeGraph {
7070
TimeGraph {
71-
data: Arc::new(Mutex::new(HashMap::new()))
71+
data: Arc::new(Mutex::new(FxHashMap::default()))
7272
}
7373
}
7474

‎src/librustc_codegen_llvm/back/linker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::collections::HashMap;
11+
use rustc_data_structures::fx::FxHashMap;
1212
use std::ffi::{OsStr, OsString};
1313
use std::fs::{self, File};
1414
use std::io::prelude::*;
@@ -30,7 +30,7 @@ use serialize::{json, Encoder};
3030
/// For all the linkers we support, and information they might
3131
/// need out of the shared crate context before we get rid of it.
3232
pub struct LinkerInfo {
33-
exports: HashMap<CrateType, Vec<String>>,
33+
exports: FxHashMap<CrateType, Vec<String>>,
3434
}
3535

3636
impl LinkerInfo {

‎src/librustc_codegen_llvm/back/rpath.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::collections::HashSet;
11+
use rustc_data_structures::fx::FxHashSet;
1212
use std::env;
1313
use std::path::{Path, PathBuf};
1414
use std::fs;
@@ -172,7 +172,7 @@ fn get_install_prefix_rpath(config: &mut RPathConfig) -> String {
172172
}
173173

174174
fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
175-
let mut set = HashSet::new();
175+
let mut set = FxHashSet::default();
176176
let mut minimized = Vec::new();
177177
for rpath in rpaths {
178178
if set.insert(rpath) {

‎src/librustc_data_structures/graph/test.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::collections::HashMap;
11+
use fx::FxHashMap;
1212
use std::cmp::max;
1313
use std::slice;
1414
use std::iter;
@@ -18,17 +18,17 @@ use super::*;
1818
pub struct TestGraph {
1919
num_nodes: usize,
2020
start_node: usize,
21-
successors: HashMap<usize, Vec<usize>>,
22-
predecessors: HashMap<usize, Vec<usize>>,
21+
successors: FxHashMap<usize, Vec<usize>>,
22+
predecessors: FxHashMap<usize, Vec<usize>>,
2323
}
2424

2525
impl TestGraph {
2626
pub fn new(start_node: usize, edges: &[(usize, usize)]) -> Self {
2727
let mut graph = TestGraph {
2828
num_nodes: start_node + 1,
2929
start_node,
30-
successors: HashMap::new(),
31-
predecessors: HashMap::new(),
30+
successors: FxHashMap::default(),
31+
predecessors: FxHashMap::default(),
3232
};
3333
for &(source, target) in edges {
3434
graph.num_nodes = max(graph.num_nodes, source + 1);

‎src/librustc_driver/profile/trace.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
use super::*;
1212
use syntax_pos::SpanData;
13+
use rustc_data_structures::fx::FxHashMap;
1314
use rustc::util::common::QueryMsg;
1415
use std::fs::File;
1516
use std::time::{Duration, Instant};
16-
use std::collections::hash_map::HashMap;
1717
use rustc::dep_graph::{DepNode};
1818

1919
#[derive(Debug, Clone, Eq, PartialEq)]
@@ -149,7 +149,7 @@ fn write_traces_rec(file: &mut File, traces: &[Rec], total: Duration, depth: usi
149149
}
150150
}
151151

152-
fn compute_counts_rec(counts: &mut HashMap<String,QueryMetric>, traces: &[Rec]) {
152+
fn compute_counts_rec(counts: &mut FxHashMap<String,QueryMetric>, traces: &[Rec]) {
153153
for t in traces.iter() {
154154
match t.effect {
155155
Effect::TimeBegin(ref msg) => {
@@ -200,7 +200,7 @@ fn compute_counts_rec(counts: &mut HashMap<String,QueryMetric>, traces: &[Rec])
200200
}
201201
}
202202

203-
pub fn write_counts(count_file: &mut File, counts: &mut HashMap<String,QueryMetric>) {
203+
pub fn write_counts(count_file: &mut File, counts: &mut FxHashMap<String,QueryMetric>) {
204204
use rustc::util::common::duration_to_secs_str;
205205
use std::cmp::Reverse;
206206

@@ -219,7 +219,7 @@ pub fn write_counts(count_file: &mut File, counts: &mut HashMap<String,QueryMetr
219219

220220
pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &[Rec]) {
221221
let capacity = traces.iter().fold(0, |acc, t| acc + 1 + t.extent.len());
222-
let mut counts : HashMap<String, QueryMetric> = HashMap::with_capacity(capacity);
222+
let mut counts = FxHashMap::with_capacity_and_hasher(capacity, Default::default());
223223
compute_counts_rec(&mut counts, traces);
224224
write_counts(counts_file, &mut counts);
225225

‎src/librustc_errors/emitter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, D
1616
use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
1717
use styled_buffer::StyledBuffer;
1818

19+
use rustc_data_structures::fx::FxHashMap;
1920
use rustc_data_structures::sync::Lrc;
2021
use atty;
2122
use std::borrow::Cow;
2223
use std::io::prelude::*;
2324
use std::io;
24-
use std::collections::HashMap;
2525
use std::cmp::{min, Reverse};
2626
use termcolor::{StandardStream, ColorChoice, ColorSpec, BufferWriter};
2727
use termcolor::{WriteColor, Color, Buffer};
@@ -1090,7 +1090,7 @@ impl EmitterWriter {
10901090
max_line_num_len + 1);
10911091

10921092
// Contains the vertical lines' positions for active multiline annotations
1093-
let mut multilines = HashMap::new();
1093+
let mut multilines = FxHashMap::default();
10941094

10951095
// Next, output the annotate source for this file
10961096
for line_idx in 0..annotated_file.lines.len() {
@@ -1109,7 +1109,7 @@ impl EmitterWriter {
11091109
width_offset,
11101110
code_offset);
11111111

1112-
let mut to_add = HashMap::new();
1112+
let mut to_add = FxHashMap::default();
11131113

11141114
for (depth, style) in depths {
11151115
if multilines.get(&depth).is_some() {

‎src/librustc_errors/registry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::collections::HashMap;
11+
use rustc_data_structures::fx::FxHashMap;
1212

1313
#[derive(Clone)]
1414
pub struct Registry {
15-
descriptions: HashMap<&'static str, &'static str>,
15+
descriptions: FxHashMap<&'static str, &'static str>,
1616
}
1717

1818
impl Registry {

0 commit comments

Comments
 (0)
Please sign in to comment.