about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-05-25 08:17:06 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-05-30 11:26:15 -0700
commit555492e427035caf4a0849580b16130ede6dcf5b (patch)
tree90007fc18a444eb1dc81ddbc0a2430fec8cdc500
parent79b3dedac3f50ec22d9fcab887f29d03ceec9406 (diff)
downloadrust-555492e427035caf4a0849580b16130ede6dcf5b.tar.gz
rust-555492e427035caf4a0849580b16130ede6dcf5b.zip
port alt to dvec
-rw-r--r--src/librustsyntax/ast_util.rs10
-rw-r--r--src/rustc/middle/trans/alt.rs11
2 files changed, 11 insertions, 10 deletions
diff --git a/src/librustsyntax/ast_util.rs b/src/librustsyntax/ast_util.rs
index fab844a5dc7..cee2032ed0d 100644
--- a/src/librustsyntax/ast_util.rs
+++ b/src/librustsyntax/ast_util.rs
@@ -1,25 +1,25 @@
 import codemap::span;
 import ast::*;
 
-fn spanned<T: copy>(lo: uint, hi: uint, t: T) -> spanned<T> {
+pure fn spanned<T: copy>(lo: uint, hi: uint, t: T) -> spanned<T> {
     respan(mk_sp(lo, hi), t)
 }
 
-fn respan<T: copy>(sp: span, t: T) -> spanned<T> {
+pure fn respan<T: copy>(sp: span, t: T) -> spanned<T> {
     {node: t, span: sp}
 }
 
-fn dummy_spanned<T: copy>(t: T) -> spanned<T> {
+pure fn dummy_spanned<T: copy>(t: T) -> spanned<T> {
     respan(dummy_sp(), t)
 }
 
 /* assuming that we're not in macro expansion */
-fn mk_sp(lo: uint, hi: uint) -> span {
+pure fn mk_sp(lo: uint, hi: uint) -> span {
     {lo: lo, hi: hi, expn_info: none}
 }
 
 // make this a const, once the compiler supports it
-fn dummy_sp() -> span { ret mk_sp(0u, 0u); }
+pure fn dummy_sp() -> span { ret mk_sp(0u, 0u); }
 
 fn path_name(p: @path) -> str { path_name_i(p.idents) }
 
diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs
index 493d1ee4ad2..3cac9f3685e 100644
--- a/src/rustc/middle/trans/alt.rs
+++ b/src/rustc/middle/trans/alt.rs
@@ -13,6 +13,7 @@ import syntax::print::pprust::pat_to_str;
 import back::abi;
 import resolve::def_map;
 import std::map::hashmap;
+import dvec::{dvec, extensions};
 
 import common::*;
 
@@ -236,12 +237,12 @@ fn enter_uniq(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
 }
 
 fn get_options(ccx: @crate_ctxt, m: match, col: uint) -> [opt] {
-    fn add_to_set(tcx: ty::ctxt, &set: [opt], val: opt) {
-        for vec::each(set) {|l| if opt_eq(tcx, l, val) { ret; } }
-        set += [val];
+    fn add_to_set(tcx: ty::ctxt, &&set: dvec<opt>, val: opt) {
+        if set.any({|l| opt_eq(tcx, l, val)}) {ret;}
+        set.push(val);
     }
 
-    let mut found = [];
+    let found = dvec();
     for vec::each(m) {|br|
         let cur = br.pats[col];
         if pat_is_variant(ccx.tcx.def_map, cur) {
@@ -256,7 +257,7 @@ fn get_options(ccx: @crate_ctxt, m: match, col: uint) -> [opt] {
             }
         }
     }
-    ret found;
+    ret vec::from_mut(dvec::unwrap(found));
 }
 
 fn extract_variant_args(bcx: block, pat_id: ast::node_id,