about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-10-12 10:14:21 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-10-12 11:05:20 +0200
commit306f7fb25f6c4eec0a0a517edb2b2821468efdf3 (patch)
tree494bd762eb2d74a252fa3c3860fcb50c0b43d4c5 /src/comp
parent75bda422df0c7816d4b987a564d11935a0cdb8db (diff)
Simplify copying of uniques
We can call take glue, rather than duplicating it inline.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/trans.rs14
-rw-r--r--src/comp/middle/trans_uniq.rs16
2 files changed, 3 insertions, 27 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 77dfde48c43..0e3e95e5f9f 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -2092,22 +2092,12 @@ fn copy_val_no_check(bcx: @block_ctxt, action: copy_action, dst: ValueRef,
         ret bcx;
     }
     if ty::type_is_nil(ccx.tcx, t) || ty::type_is_bot(ccx.tcx, t) { ret bcx; }
-    if ty::type_is_boxed(ccx.tcx, t) {
+    if ty::type_is_boxed(ccx.tcx, t) || ty::type_is_vec(ccx.tcx, t) ||
+       ty::type_is_unique_box(ccx.tcx, t) {
         if action == DROP_EXISTING { bcx = drop_ty(bcx, dst, t); }
         Store(bcx, src, dst);
         ret take_ty(bcx, dst, t);
     }
-    if ty::type_is_vec(ccx.tcx, t) {
-        if action == DROP_EXISTING { bcx = drop_ty(bcx, dst, t); }
-        let {bcx, val} = tvec::duplicate(bcx, src, t);
-        Store(bcx, val, dst);
-        ret bcx;
-    }
-    if ty::type_is_unique_box(ccx.tcx, t) {
-        if action == DROP_EXISTING { bcx = drop_ty(bcx, dst, t); }
-        check trans_uniq::type_is_unique_box(bcx, t);
-        ret trans_uniq::copy_val(bcx, dst, src, t);
-    }
     if type_is_structural_or_param(ccx.tcx, t) {
         if action == DROP_EXISTING { bcx = drop_ty(bcx, dst, t); }
         bcx = memmove_ty(bcx, dst, src, t);
diff --git a/src/comp/middle/trans_uniq.rs b/src/comp/middle/trans_uniq.rs
index 67e55ef6f5b..f1df608e8bf 100644
--- a/src/comp/middle/trans_uniq.rs
+++ b/src/comp/middle/trans_uniq.rs
@@ -15,8 +15,7 @@ import trans::{
     dest
 };
 
-export trans_uniq, make_free_glue, type_is_unique_box, copy_val,
-autoderef, duplicate;
+export trans_uniq, make_free_glue, type_is_unique_box, autoderef, duplicate;
 
 pure fn type_is_unique_box(bcx: @block_ctxt, ty: ty::t) -> bool {
     ty::type_is_unique_box(bcx_tcx(bcx), ty)
@@ -77,19 +76,6 @@ fn content_ty(bcx: @block_ctxt, t: ty::t)
     }
 }
 
-fn copy_val(cx: @block_ctxt, dst: ValueRef, src: ValueRef,
-            ty: ty::t) : type_is_unique_box(cx, ty) -> @block_ctxt {
-
-    let content_ty = content_ty(cx, ty);
-    let {bcx, val: llptr} = alloc_uniq(cx, ty);
-    Store(bcx, llptr, dst);
-
-    let src = load_if_immediate(bcx, src, content_ty);
-    let dst = llptr;
-    let bcx = trans::copy_val(bcx, INIT, dst, src, content_ty);
-    ret bcx;
-}
-
 fn autoderef(bcx: @block_ctxt, v: ValueRef, t: ty::t)
     : type_is_unique_box(bcx, t) -> {v: ValueRef, t: ty::t} {