From 1f8f6054d283f7a2d5e5277f422463bfaecbe139 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 15 Dec 2011 17:25:58 -0800 Subject: [PATCH] rustc: Box tag variants to avoid copies --- src/comp/metadata/decoder.rs | 2 +- src/comp/middle/ty.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/comp/metadata/decoder.rs b/src/comp/metadata/decoder.rs index bd8c02d0cb7a..d5d981bb81c4 100644 --- a/src/comp/metadata/decoder.rs +++ b/src/comp/metadata/decoder.rs @@ -244,7 +244,7 @@ fn get_tag_variants(_data: @[u8], def: ast::def_id, tcx: ty::ctxt, } } - infos += [{args: arg_tys, ctor_ty: ctor_ty, id: did}]; + infos += [@{args: arg_tys, ctor_ty: ctor_ty, id: did}]; } ret infos; } diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 57ef16ded610..2ff7f0b1b747 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -2721,7 +2721,7 @@ fn def_has_ty_params(def: ast::def) -> bool { // Tag information -type variant_info = {args: [ty::t], ctor_ty: ty::t, id: ast::def_id}; +type variant_info = @{args: [ty::t], ctor_ty: ty::t, id: ast::def_id}; fn tag_variants(cx: ctxt, id: ast::def_id) -> @mutable [variant_info] { if ast::local_crate != id.crate { @@ -2752,9 +2752,9 @@ fn tag_variants(cx: ctxt, id: ast::def_id) -> @mutable [variant_info] { } let did = variant.node.id; *result += - [{args: arg_tys, - ctor_ty: ctor_ty, - id: ast_util::local_def(did)}]; + [@{args: arg_tys, + ctor_ty: ctor_ty, + id: ast_util::local_def(did)}]; } smallintmap::insert(*cx.tag_var_cache, id.node as uint, result); ret result;