News for hackers. Stuff that matters.
Re:Why blocks make Ruby methods slower by trustfundbaby on Friday February 27, 2015 @11:31PM (#9122789)
> I mean, if both methods behave the same, what is the difference?

Not much. They just optimized the yield case so its basically skips the red tape.

"As it turns out, MRI has optimized this common case, providing an entirely separate pathway, from parsing through execution, for blockless yields (it's actually a primitive in YARV, the meta-language to which Ruby is compiled at execution time). Because of this special pathway, calls to yield end up being handled by a dedicated C function in the interpreter (vm_invoke_block in vm_inshelper.c, if you're interested), and are much faster than their explicitly blocked bretheren"

There are no comments on this comment yet.