ruby / delegate

This library provides three different ways to delegate method calls to an object.
BSD 2-Clause "Simplified" License
18 stars 13 forks source link

Let DelegateClass respect the original method's arity in case of 0 #16

Open amatsuda opened 1 year ago

amatsuda commented 1 year ago

Further description is at https://bugs.ruby-lang.org/issues/19287

This defines 37% faster method when it takes no argument.

Benchmark: Warming up -------------------------------------- old 551.697k i/100ms new 721.906k i/100ms Calculating ------------------------------------- old 6.511M (± 0.8%) i/s - 33.102M in 5.084530s new 8.925M (± 1.0%) i/s - 44.758M in 5.015619s

Comparison: new: 8924652.2 i/s old: 6510691.1 i/s - 1.37x (± 0.00) slower

eregon commented 1 year ago

This would break if the target method is later redefined with non-0 arity and called with 1+ arguments. I'm not sure how much that matters though.