1
Fork 0

Merge pull request #4585 from thestinger/map

migrate LinearMap<T, ()> to LinearSet<T>
This commit is contained in:
Graydon Hoare 2013-01-22 19:52:39 -08:00
commit 2c870e4074
5 changed files with 18 additions and 24 deletions

View file

@ -44,7 +44,7 @@ use io;
use libc::{size_t, uintptr_t};
use option::{None, Option, Some};
use ptr;
use send_map::linear::LinearMap;
use send_map::linear::LinearSet;
use stackwalk;
use sys;
@ -294,12 +294,6 @@ pub fn gc() {
}
}
type RootSet = LinearMap<*Word,()>;
fn RootSet() -> RootSet {
LinearMap()
}
#[cfg(gc)]
fn expect_sentinel() -> bool { true }
@ -337,13 +331,13 @@ pub fn cleanup_stack_for_failure() {
ptr::null()
};
let mut roots = ~RootSet();
let mut roots = LinearSet::new();
for walk_gc_roots(need_cleanup, sentinel) |root, tydesc| {
// Track roots to avoid double frees.
if roots.find(&*root).is_some() {
if roots.contains(&*root) {
loop;
}
roots.insert(*root, ());
roots.insert(*root);
if ptr::is_null(tydesc) {
// FIXME #4420: Destroy this box

View file

@ -485,7 +485,7 @@ pub mod linear {
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
}
impl <T: Hash IterBytes Eq> LinearSet<T> {
pub impl <T: Hash IterBytes Eq> LinearSet<T> {
/// Create an empty LinearSet
static fn new() -> LinearSet<T> { LinearSet{map: LinearMap()} }
}

View file

@ -96,13 +96,13 @@ macro_rules! move_it (
{ $x:expr } => ( unsafe { let y = move *ptr::addr_of(&($x)); move y } )
)
type TaskSet = send_map::linear::LinearMap<*rust_task,()>;
type TaskSet = send_map::linear::LinearSet<*rust_task>;
fn new_taskset() -> TaskSet {
send_map::linear::LinearMap()
send_map::linear::LinearSet::new()
}
fn taskset_insert(tasks: &mut TaskSet, task: *rust_task) {
let didnt_overwrite = tasks.insert(task, ());
let didnt_overwrite = tasks.insert(task);
assert didnt_overwrite;
}
fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) {
@ -110,7 +110,7 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) {
assert was_present;
}
pub fn taskset_each(tasks: &TaskSet, blk: fn(v: *rust_task) -> bool) {
tasks.each_key(|k| blk(*k))
tasks.each(|k| blk(*k))
}
// One of these per group of linked-failure tasks.

View file

@ -30,7 +30,7 @@ use util::common::indenter;
use util::ppaux::{expr_repr, region_to_str};
use core::dvec;
use core::send_map::linear::LinearMap;
use core::send_map::linear::LinearSet;
use core::vec;
use std::map::HashMap;
use syntax::ast::{m_const, m_imm, m_mutbl};
@ -73,7 +73,7 @@ enum gather_loan_ctxt = @{bccx: borrowck_ctxt,
req_maps: req_maps,
mut item_ub: ast::node_id,
mut root_ub: ast::node_id,
mut ignore_adjustments: LinearMap<ast::node_id,()>};
mut ignore_adjustments: LinearSet<ast::node_id>};
fn gather_loans(bccx: borrowck_ctxt, crate: @ast::crate) -> req_maps {
let glcx = gather_loan_ctxt(@{bccx: bccx,
@ -81,7 +81,7 @@ fn gather_loans(bccx: borrowck_ctxt, crate: @ast::crate) -> req_maps {
pure_map: HashMap()},
mut item_ub: 0,
mut root_ub: 0,
mut ignore_adjustments: LinearMap()});
mut ignore_adjustments: LinearSet::new()});
let v = visit::mk_vt(@visit::Visitor {visit_expr: req_loans_in_expr,
visit_fn: req_loans_in_fn,
visit_stmt: add_stmt_to_map,
@ -126,7 +126,7 @@ fn req_loans_in_expr(ex: @ast::expr,
ex.id, pprust::expr_to_str(ex, tcx.sess.intr()));
// If this expression is borrowed, have to ensure it remains valid:
if !self.ignore_adjustments.contains_key(&ex.id) {
if !self.ignore_adjustments.contains(&ex.id) {
for tcx.adjustments.find(ex.id).each |adjustments| {
self.guarantee_adjustments(ex, *adjustments);
}
@ -221,7 +221,7 @@ fn req_loans_in_expr(ex: @ast::expr,
// FIXME (#3387): Total hack: Ignore adjustments for the left-hand
// side. Their regions will be inferred to be too large.
self.ignore_adjustments.insert(rcvr.id, ());
self.ignore_adjustments.insert(rcvr.id);
visit::visit_expr(ex, self, vt);
}

View file

@ -693,18 +693,18 @@ impl CoherenceChecker {
let tcx = self.crate_context.tcx;
let mut provided_names = send_map::linear::LinearMap();
let mut provided_names = send_map::linear::LinearSet::new();
// Implemented methods
for uint::range(0, all_methods.len()) |i| {
provided_names.insert(all_methods[i].ident, ());
provided_names.insert(all_methods[i].ident);
}
// Default methods
for ty::provided_trait_methods(tcx, trait_did).each |ident| {
provided_names.insert(*ident, ());
provided_names.insert(*ident);
}
for (*ty::trait_methods(tcx, trait_did)).each |method| {
if provided_names.contains_key(&method.ident) { loop; }
if provided_names.contains(&method.ident) { loop; }
tcx.sess.span_err(trait_ref_span,
fmt!("missing method `%s`",