From 05d36965dff534d5976d4b3d7c443813992bdec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Wed, 26 Aug 2015 19:41:27 +0200 Subject: [PATCH] Avoid an extra alloca/memcpy when auto-ref'ing fat pointers auto_ref() handles fat pointers just fine and unlike ref_fat_ptr() does so without creating an unnecessary copy of the pointer. --- src/librustc_trans/trans/expr.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index efccba91650ca..7307cd136d7a9 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -390,14 +390,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // (You might think there is a more elegant way to do this than a // skip_reborrows bool, but then you remember that the borrow checker exists). if skip_reborrows == 0 && adj.autoref.is_some() { - if !type_is_sized(bcx.tcx(), datum.ty) { - // Arrange cleanup - let lval = unpack_datum!(bcx, - datum.to_lvalue_datum(bcx, "ref_fat_ptr", expr.id)); - datum = unpack_datum!(bcx, ref_fat_ptr(bcx, lval)); - } else { - datum = unpack_datum!(bcx, auto_ref(bcx, datum, expr)); - } + datum = unpack_datum!(bcx, auto_ref(bcx, datum, expr)); } if let Some(target) = adj.unsize {