From bdd20000665a35e14b4ec2c54f893fc80fe451ef Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Wed, 13 Jun 2012 10:46:33 -0700 Subject: [PATCH] Some cleanup in tvec. --- src/rustc/middle/trans/tvec.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index b220ec7cd42..0760bdaf24e 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -69,18 +69,15 @@ fn alloc_uniq(bcx: block, unit_ty: ty::t, elts: uint) -> result { fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result { let _icx = bcx.insn_ctxt("tvec::duplicate_uniq"); - let ccx = bcx.ccx(); - let body_ptr = get_bodyptr(bcx, vptr); - let fill = get_fill(bcx, body_ptr); - let size = Add(bcx, fill, llsize_of(ccx, ccx.opaque_vec_type)); + let fill = get_fill(bcx, get_bodyptr(bcx, vptr)); let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty); - let vecbodyty = ty::mk_mut_unboxed_vec(bcx.tcx(), unit_ty); - let {box: newptr, body: new_body_ptr} = - base::malloc_unique_dyn(bcx, vecbodyty, size); - call_memmove(bcx, new_body_ptr, body_ptr, size); + let {bcx, val: newptr} = alloc_uniq_raw(bcx, unit_ty, fill, fill); + + let data_ptr = get_dataptr(bcx, get_bodyptr(bcx, vptr)); + let new_data_ptr = get_dataptr(bcx, get_bodyptr(bcx, newptr)); + call_memmove(bcx, new_data_ptr, data_ptr, fill); - Store(bcx, fill, GEPi(bcx, new_body_ptr, [0u, abi::vec_elt_alloc])); let bcx = if ty::type_needs_drop(bcx.tcx(), unit_ty) { iter_vec(bcx, newptr, vec_ty, base::take_ty) } else { bcx };