From de1513f26a4f2d645c07d70aa00aa420037ef888 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 15 May 2012 13:40:01 -0700 Subject: [PATCH] port interner to use dvec --- src/librustsyntax/util/interner.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/librustsyntax/util/interner.rs b/src/librustsyntax/util/interner.rs index 99a032aae94..89078bfaa36 100644 --- a/src/librustsyntax/util/interner.rs +++ b/src/librustsyntax/util/interner.rs @@ -3,25 +3,26 @@ // type, and vice versa. import std::map; import std::map::{hashmap, hashfn, eqfn}; +import dvec::{dvec, extensions}; type interner = {map: hashmap, - mut vect: [T], + vect: dvec, hasher: hashfn, eqer: eqfn}; fn mk(hasher: hashfn, eqer: eqfn) -> interner { let m = map::hashmap::(hasher, eqer); - ret {map: m, mut vect: [], hasher: hasher, eqer: eqer}; + ret {map: m, vect: dvec(), hasher: hasher, eqer: eqer}; } fn intern(itr: interner, val: T) -> uint { alt itr.map.find(val) { some(idx) { ret idx; } none { - let new_idx = vec::len::(itr.vect); + let new_idx = itr.vect.len(); itr.map.insert(val, new_idx); - itr.vect += [val]; + itr.vect.push(val); ret new_idx; } } @@ -32,8 +33,8 @@ fn intern(itr: interner, val: T) -> uint { // where we first check a pred and then rely on it, ceasing to fail is ok. pure fn get(itr: interner, idx: uint) -> T { unchecked { - itr.vect[idx] + itr.vect.get_elt(idx) } } -fn len(itr: interner) -> uint { ret vec::len(itr.vect); } +fn len(itr: interner) -> uint { ret itr.vect.len(); }