Skip to content

Commit

Permalink
use BTreeMap
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Feb 14, 2024
1 parent dd327f5 commit 1e32922
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_borrowck/src/region_infer/values.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::fx::FxIndexSet;
use rustc_index::bit_set::SparseBitMatrix;
use rustc_index::interval::IntervalSet;
use rustc_index::interval::SparseIntervalMatrix;
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::unord::UnordMap;
use rustc_errors::{DiagCtxt, FatalError};
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_middle::bug;
use rustc_middle::dep_graph::WorkProduct;
use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel};
use rustc_session::config::{self, CrateType, Lto};

use std::collections::BTreeMap;
use std::ffi::{CStr, CString};
use std::fs::File;
use std::io;
Expand Down Expand Up @@ -788,7 +788,7 @@ pub unsafe fn optimize_thin_module(
#[derive(Debug, Default)]
pub struct ThinLTOKeysMap {
// key = llvm name of importing module, value = LLVM cache key
keys: UnordMap<String, String>,
keys: BTreeMap<String, String>,
}

impl ThinLTOKeysMap {
Expand All @@ -798,15 +798,15 @@ impl ThinLTOKeysMap {
let mut writer = io::BufWriter::new(file);
// The entries are loaded back into a hash map in `load_from_file()`, so
// the order in which we write them to file here does not matter.
for (module, key) in self.keys.items().into_sorted_stable_ord() {
for (module, key) in &self.keys {
writeln!(writer, "{module} {key}")?;
}
Ok(())
}

fn load_from_file(path: &Path) -> io::Result<Self> {
use std::io::BufRead;
let mut keys = UnordMap::default();
let mut keys = BTreeMap::default();
let file = File::open(path)?;
for line in io::BufReader::new(file).lines() {
let line = line?;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,8 @@ impl CrateInfo {
.collect();
let prefix = if target.is_like_windows && target.arch == "x86" { "_" } else { "" };

// This loop only adds new items to values of the hash map, so the order in which we
// iterate over the values is not important.
#[allow(rustc::potential_query_instability)]
info.linked_symbols
.iter_mut()
Expand Down

0 comments on commit 1e32922

Please sign in to comment.