Skip to content

Commit bdd2000

Browse files
committed
Some cleanup in tvec.
1 parent 920ea63 commit bdd2000

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/rustc/middle/trans/tvec.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,15 @@ fn alloc_uniq(bcx: block, unit_ty: ty::t, elts: uint) -> result {
6969

7070
fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result {
7171
let _icx = bcx.insn_ctxt("tvec::duplicate_uniq");
72-
let ccx = bcx.ccx();
73-
let body_ptr = get_bodyptr(bcx, vptr);
74-
let fill = get_fill(bcx, body_ptr);
75-
let size = Add(bcx, fill, llsize_of(ccx, ccx.opaque_vec_type));
7672

73+
let fill = get_fill(bcx, get_bodyptr(bcx, vptr));
7774
let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
78-
let vecbodyty = ty::mk_mut_unboxed_vec(bcx.tcx(), unit_ty);
79-
let {box: newptr, body: new_body_ptr} =
80-
base::malloc_unique_dyn(bcx, vecbodyty, size);
81-
call_memmove(bcx, new_body_ptr, body_ptr, size);
75+
let {bcx, val: newptr} = alloc_uniq_raw(bcx, unit_ty, fill, fill);
76+
77+
let data_ptr = get_dataptr(bcx, get_bodyptr(bcx, vptr));
78+
let new_data_ptr = get_dataptr(bcx, get_bodyptr(bcx, newptr));
79+
call_memmove(bcx, new_data_ptr, data_ptr, fill);
8280

83-
Store(bcx, fill, GEPi(bcx, new_body_ptr, [0u, abi::vec_elt_alloc]));
8481
let bcx = if ty::type_needs_drop(bcx.tcx(), unit_ty) {
8582
iter_vec(bcx, newptr, vec_ty, base::take_ty)
8683
} else { bcx };

0 commit comments

Comments
 (0)