@@ -69,18 +69,15 @@ fn alloc_uniq(bcx: block, unit_ty: ty::t, elts: uint) -> result {
69
69
70
70
fn duplicate_uniq ( bcx : block , vptr : ValueRef , vec_ty : ty:: t ) -> result {
71
71
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 ) ) ;
76
72
73
+ let fill = get_fill ( bcx, get_bodyptr ( bcx, vptr) ) ;
77
74
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) ;
82
80
83
- Store ( bcx, fill, GEPi ( bcx, new_body_ptr, [ 0 u, abi:: vec_elt_alloc] ) ) ;
84
81
let bcx = if ty:: type_needs_drop ( bcx. tcx ( ) , unit_ty) {
85
82
iter_vec ( bcx, newptr, vec_ty, base:: take_ty)
86
83
} else { bcx } ;
0 commit comments