2 ms·
Why is attr_reader :foo faster than def foo;@foo;end Is this in 1.9.x? or 1.8.x? or both?
by rnicholson 16y ago
Why is
attr_reader :foo
faster than
def foo;@foo;end
Is this in 1.9.x? or 1.8.x? or both?
- texel 16y agoCourtesy of Evan Phoenix... apparently in MRI, attr_reader doesn't create a method, instead creating a NODE_IVAR in the method table of the class. This circumvents method creation/invocation overhead and is therefore faster.