# Code Review: Control Flow Optimizations

**URL:** <https://www.ruby-forum.com/t/code-review-control-flow-optimizations/183147>\
**Category:** IronRuby\
**Created:** [February 8, 2010, 11:12pm UTC](https://www.ruby-forum.com/t/code-review-control-flow-optimizations/183147 "2010-02-08T23:12:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grujildo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@grujildo](https://www.ruby-forum.com/u/grujildo)\
**Post date:** [February 8, 2010, 11:12pm UTC](https://www.ruby-forum.com/t/code-review-control-flow-optimizations/183147/1 "2010-02-08T23:12:13Z")

</div>

1. 

```
 Implements a new block return optimization. It targets frame 

```

unwinding in the cases of returning from (nested) blocks like these:

def foo  
x.times do  
y.times do  
return  
end  
end  
end

We were throwing an exception in such cases to unwind the block frames.  
This is unnecessary because we already handle other kinds of  
control-flow (retry) in call sites with a block (x.times and y.times in  
the example above). So adding one more check (for frame unwinding  
return) there enables us to not throw an exception and doesn’t slow down  
the fast path (no cross-frame control flow).

1. 

```
 Removes an unnecessary allocation in dynamic call sites that 

```

dispatch to a Ruby method and take a block.

1. 

```
 Adds targeted unit tests to increase code coverage of control 

```

flow constructs.

Tomas
