* dropnzero_val fn added

* zero-mem for not needed drop situation placed in Ignore
This commit is contained in:
Mahmut Bulut 2012-10-30 23:37:09 +02:00
parent a3b83c6224
commit bf792b922c
2 changed files with 20 additions and 1 deletions

View File

@ -542,6 +542,25 @@ impl Datum {
};
}
fn dropnzero_val(bcx: block) -> block {
if !ty::type_needs_drop(bcx.tcx(), self.ty) {
return bcx;
}
return match self.mode {
ByRef => {
glue::drop_ty(bcx, self.val, self.ty);
zero_mem(bcx, self.val, self.ty);
return bcx;
}
ByValue => {
glue::drop_ty_immediate(bcx, self.val, self.ty);
zero_mem(bcx, self.val, self.ty);
return bcx;
}
};
}
fn box_body(bcx: block) -> Datum {
/*!
*

View File

@ -573,7 +573,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
if bcx.expr_is_lval(a) {
let datum = unpack_datum!(bcx, trans_to_datum(bcx, a));
return match dest {
Ignore => datum.drop_val(bcx),
Ignore => datum.dropnzero_val(bcx),
SaveIn(addr) => datum.move_to(bcx, INIT, addr)
};
} else {