Skip to content

Commit 405720a

Browse files
committed
review feedback: use FxHashSet rather than sorted Vec for set-comparison slow-path.
1 parent 60c07c8 commit 405720a

File tree

1 file changed

+5
-7
lines changed
  • src/librustc_codegen_llvm/back

1 file changed

+5
-7
lines changed

src/librustc_codegen_llvm/back/lto.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc::hir::def_id::LOCAL_CRATE;
1515
use rustc::middle::exported_symbols::SymbolExportLevel;
1616
use rustc::session::config::{self, Lto};
1717
use rustc::util::common::time_ext;
18-
use rustc_data_structures::fx::FxHashMap;
18+
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
1919
use rustc_codegen_ssa::{RLIB_BYTECODE_EXTENSION, ModuleCodegen, ModuleKind};
2020

2121
use std::ffi::{CStr, CString};
@@ -584,13 +584,11 @@ fn thin_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
584584
fn equivalent_as_sets(a: &[String], b: &[String]) -> bool {
585585
// cheap path: unequal lengths means cannot possibly be set equivalent.
586586
if a.len() != b.len() { return false; }
587-
// fast path: before sorting, check if inputs are equivalent as is.
587+
// fast path: before building new things, check if inputs are equivalent as is.
588588
if a == b { return true; }
589-
// slow path: compare sorted contents
590-
let mut a: Vec<&str> = a.iter().map(|s| s.as_str()).collect();
591-
let mut b: Vec<&str> = b.iter().map(|s| s.as_str()).collect();
592-
a.sort();
593-
b.sort();
589+
// slow path: general set comparison.
590+
let a: FxHashSet<&str> = a.iter().map(|s| s.as_str()).collect();
591+
let b: FxHashSet<&str> = b.iter().map(|s| s.as_str()).collect();
594592
a == b
595593
}
596594

0 commit comments

Comments
 (0)