In Ruby it's more memory efficient (and more faster) to avoid passing named block arguments. Depending on the block context the binding object required to create a named block may be quite large. And in AR models with associations it is indeed large.
This patch avoids named blocks in associations by replacing all occurences of:
def foo(&block)
bar(&block)
end
with
def foo
bar { |*block_args| yield(*block_args) if block_given?
end
The effect of course depends on the number of associations in the AR model and the number of calls to those associations.
In my case that saves 5 megabytes of memory and 100 ms when updating 100 AR objects (each have 6 associations) and also about the same amount of memory and time when rendering them.
Please see the blog post for details: http://blog.pluron.com/2008/02/rails-faster-as.html