File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 3
3
// type, and vice versa.
4
4
import std:: map;
5
5
import std:: map:: { hashmap, hashfn, eqfn} ;
6
+ import dvec:: { dvec, extensions} ;
6
7
7
8
type interner < T > =
8
9
{ map : hashmap < T , uint > ,
9
- mut vect : [ T ] ,
10
+ vect : dvec < T > ,
10
11
hasher : hashfn < T > ,
11
12
eqer : eqfn < T > } ;
12
13
13
14
fn mk < T : copy > ( hasher : hashfn < T > , eqer : eqfn < T > ) -> interner < T > {
14
15
let m = map:: hashmap :: < T , uint > ( hasher, eqer) ;
15
- ret { map : m, mut vect : [ ] , hasher : hasher, eqer : eqer} ;
16
+ ret { map : m, vect : dvec ( ) , hasher : hasher, eqer : eqer} ;
16
17
}
17
18
18
19
fn intern < T : copy > ( itr : interner < T > , val : T ) -> uint {
19
20
alt itr. map . find ( val) {
20
21
some ( idx) { ret idx; }
21
22
none {
22
- let new_idx = vec :: len :: < T > ( itr. vect ) ;
23
+ let new_idx = itr. vect . len ( ) ;
23
24
itr. map . insert ( val, new_idx) ;
24
- itr. vect += [ val] ;
25
+ itr. vect . push ( val) ;
25
26
ret new_idx;
26
27
}
27
28
}
@@ -32,8 +33,8 @@ fn intern<T: copy>(itr: interner<T>, val: T) -> uint {
32
33
// where we first check a pred and then rely on it, ceasing to fail is ok.
33
34
pure fn get < T : copy > ( itr : interner < T > , idx : uint ) -> T {
34
35
unchecked {
35
- itr. vect [ idx]
36
+ itr. vect . get_elt ( idx)
36
37
}
37
38
}
38
39
39
- fn len < T > ( itr : interner < T > ) -> uint { ret vec :: len ( itr. vect ) ; }
40
+ fn len < T > ( itr : interner < T > ) -> uint { ret itr. vect . len ( ) ; }
You can’t perform that action at this time.
0 commit comments