Skip to content

Commit

Permalink
Rollup merge of rust-lang#50740 - nnethercote:rm-LazyBTreeMap, r=cram…
Browse files Browse the repository at this point in the history
…ertj

Remove LazyBTreeMap.

It was introduced in rust-lang#50240 to avoid an allocation when creating a new
BTreeMap, which gave some speed-ups. But then rust-lang#50352 made that the
default behaviour for BTreeMap, so LazyBTreeMap is no longer necessary.
  • Loading branch information
kennytm authored May 15, 2018
2 parents c48f925 + f46b888 commit 5a8e1ad
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 123 deletions.
12 changes: 5 additions & 7 deletions src/librustc/infer/higher_ranked/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ use super::{CombinedSnapshot,
use super::combine::CombineFields;
use super::region_constraints::{TaintDirections};

use rustc_data_structures::lazy_btree_map::LazyBTreeMap;
use ty::{self, TyCtxt, Binder, TypeFoldable};
use ty::error::TypeError;
use ty::relate::{Relate, RelateResult, TypeRelation};
use std::collections::BTreeMap;
use syntax_pos::Span;
use util::nodemap::{FxHashMap, FxHashSet};

Expand Down Expand Up @@ -247,8 +247,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
snapshot: &CombinedSnapshot<'a, 'tcx>,
debruijn: ty::DebruijnIndex,
new_vars: &[ty::RegionVid],
a_map: &LazyBTreeMap<ty::BoundRegion,
ty::Region<'tcx>>,
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
r0: ty::Region<'tcx>)
-> ty::Region<'tcx> {
// Regions that pre-dated the LUB computation stay as they are.
Expand Down Expand Up @@ -344,8 +343,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
snapshot: &CombinedSnapshot<'a, 'tcx>,
debruijn: ty::DebruijnIndex,
new_vars: &[ty::RegionVid],
a_map: &LazyBTreeMap<ty::BoundRegion,
ty::Region<'tcx>>,
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
a_vars: &[ty::RegionVid],
b_vars: &[ty::RegionVid],
r0: ty::Region<'tcx>)
Expand Down Expand Up @@ -414,7 +412,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {

fn rev_lookup<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
span: Span,
a_map: &LazyBTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
r: ty::Region<'tcx>) -> ty::Region<'tcx>
{
for (a_br, a_r) in a_map {
Expand All @@ -437,7 +435,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
}

fn var_ids<'a, 'gcx, 'tcx>(fields: &CombineFields<'a, 'gcx, 'tcx>,
map: &LazyBTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
-> Vec<ty::RegionVid> {
map.iter()
.map(|(_, &r)| match *r {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
use ty::fold::TypeFoldable;
use ty::relate::RelateResult;
use traits::{self, ObligationCause, PredicateObligations};
use rustc_data_structures::lazy_btree_map::LazyBTreeMap;
use rustc_data_structures::unify as ut;
use std::cell::{Cell, RefCell, Ref, RefMut};
use std::collections::BTreeMap;
use std::fmt;
use syntax::ast;
use errors::DiagnosticBuilder;
Expand Down Expand Up @@ -198,7 +198,7 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {

/// A map returned by `skolemize_late_bound_regions()` indicating the skolemized
/// region that each late-bound region was replaced with.
pub type SkolemizationMap<'tcx> = LazyBTreeMap<ty::BoundRegion, ty::Region<'tcx>>;
pub type SkolemizationMap<'tcx> = BTreeMap<ty::BoundRegion, ty::Region<'tcx>>;

/// See `error_reporting` module for more details
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -1236,7 +1236,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
span: Span,
lbrct: LateBoundRegionConversionTime,
value: &ty::Binder<T>)
-> (T, LazyBTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
-> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
where T : TypeFoldable<'tcx>
{
self.tcx.replace_late_bound_regions(
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use middle::const_val::ConstVal;
use hir::def_id::DefId;
use ty::{self, Binder, Ty, TyCtxt, TypeFlags};

use rustc_data_structures::lazy_btree_map::LazyBTreeMap;
use std::collections::BTreeMap;
use std::fmt;
use util::nodemap::FxHashSet;

Expand Down Expand Up @@ -328,7 +328,7 @@ struct RegionReplacer<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
current_depth: u32,
fld_r: &'a mut (dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx> + 'a),
map: LazyBTreeMap<ty::BoundRegion, ty::Region<'tcx>>
map: BTreeMap<ty::BoundRegion, ty::Region<'tcx>>
}

impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
Expand All @@ -343,7 +343,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn replace_late_bound_regions<T,F>(self,
value: &Binder<T>,
mut f: F)
-> (T, LazyBTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
-> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
where F : FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
T : TypeFoldable<'tcx>,
{
Expand Down Expand Up @@ -456,7 +456,7 @@ impl<'a, 'gcx, 'tcx> RegionReplacer<'a, 'gcx, 'tcx> {
tcx,
current_depth: 1,
fld_r,
map: LazyBTreeMap::default()
map: BTreeMap::default()
}
}
}
Expand Down
108 changes: 0 additions & 108 deletions src/librustc_data_structures/lazy_btree_map.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ pub mod bitvec;
pub mod graph;
pub mod indexed_set;
pub mod indexed_vec;
pub mod lazy_btree_map;
pub mod obligation_forest;
pub mod sip128;
pub mod snapshot_map;
Expand Down

0 comments on commit 5a8e1ad

Please sign in to comment.