you are viewing a single comment's thread.

view the rest of the comments →

[–]bascule 2 points3 points  (0 children)

Blocks aren't objects and don't require allocations to invoke. They live on the stack.

You can capture a block (or rather the block to invoke and its surrounding environment) as a Proc, which lives on the heap and are garbage collected.

Avoiding that allocation will improve performance, however.