Skip to content

Commit d405117

Browse files
committed
Avoid creating llenv blocks when there's nothing to load
Currently, all closures have an llenv block to load values from the captured environment, but for closure that don't actually capture anything, that block is useless and can be skipped.
1 parent c4b6216 commit d405117

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/librustc/middle/trans/closure.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ pub fn load_environment(fcx: fn_ctxt,
326326
sigil: ast::Sigil) {
327327
let _icx = push_ctxt("closure::load_environment");
328328

329+
// Don't bother to create the block if there's nothing to load
330+
if cap_vars.len() == 0 && !load_ret_handle {
331+
return;
332+
}
333+
329334
let llloadenv = match fcx.llloadenv {
330335
Some(ll) => ll,
331336
None => {

0 commit comments

Comments
 (0)