diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 380a512d17b2..252a10f8a8bb 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -409,6 +409,15 @@ pub fn trans_expr_fn(bcx: block, ~"expr_fn"); let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty); + // Always mark inline if this is a loop body. This is important for + // performance on many programs with tight loops. + if is_loop_body.is_some() { + set_always_inline(llfn); + } else { + // Can't hurt. + set_inline_hint(llfn); + } + let Result {bcx: bcx, val: closure} = match sigil { ast::BorrowedSigil | ast::ManagedSigil | ast::OwnedSigil => { let cap_vars = *ccx.maps.capture_map.get(&user_id);