提交 c7eee8fb 编写于 作者: M Marijn Haverbeke

Stop registering cleanups for types that don't need them

上级 31586339
...@@ -264,11 +264,13 @@ ...@@ -264,11 +264,13 @@
} }
fn add_clean(cx: @block_ctxt, val: ValueRef, ty: ty::t) { fn add_clean(cx: @block_ctxt, val: ValueRef, ty: ty::t) {
if !ty::type_needs_drop(bcx_tcx(cx), ty) { ret; }
let scope_cx = find_scope_cx(cx); let scope_cx = find_scope_cx(cx);
scope_cx.cleanups += [clean(bind drop_ty(_, val, ty))]; scope_cx.cleanups += [clean(bind drop_ty(_, val, ty))];
scope_cx.lpad_dirty = true; scope_cx.lpad_dirty = true;
} }
fn add_clean_temp(cx: @block_ctxt, val: ValueRef, ty: ty::t) { fn add_clean_temp(cx: @block_ctxt, val: ValueRef, ty: ty::t) {
if !ty::type_needs_drop(bcx_tcx(cx), ty) { ret; }
fn spill_and_drop(cx: @block_ctxt, val: ValueRef, ty: ty::t) -> fn spill_and_drop(cx: @block_ctxt, val: ValueRef, ty: ty::t) ->
@block_ctxt { @block_ctxt {
let bcx = cx; let bcx = cx;
...@@ -283,6 +285,7 @@ fn spill_and_drop(cx: @block_ctxt, val: ValueRef, ty: ty::t) -> ...@@ -283,6 +285,7 @@ fn spill_and_drop(cx: @block_ctxt, val: ValueRef, ty: ty::t) ->
scope_cx.lpad_dirty = true; scope_cx.lpad_dirty = true;
} }
fn add_clean_temp_mem(cx: @block_ctxt, val: ValueRef, ty: ty::t) { fn add_clean_temp_mem(cx: @block_ctxt, val: ValueRef, ty: ty::t) {
if !ty::type_needs_drop(bcx_tcx(cx), ty) { ret; }
let scope_cx = find_scope_cx(cx); let scope_cx = find_scope_cx(cx);
scope_cx.cleanups += [clean_temp(val, bind drop_ty(_, val, ty))]; scope_cx.cleanups += [clean_temp(val, bind drop_ty(_, val, ty))];
scope_cx.lpad_dirty = true; scope_cx.lpad_dirty = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册