Summary: An artificial test on indirection shows that indirection is slower than no indirection by a significant amount. A bit pointless imo. It would be more interesting to talk about maintainability, flexibility and overhead when avoiding this kind of indirection inside hot loops but allowing it outside, in 'management' code.
Exactly. You have so much 'OOP Bad' stuff posted, which newbies read and just assume OOP bad. In this case, it's only bad when that difference in performance matters. In a huge amount of code, it just doesn't, and the benefits of using it are pretty much pure win. Even in a lot of cases where it might impact performance a little bit, it will probably still be a win if it makes the code easier to maintain and more flexible.
30
u/SirB May 26 '22
Summary: An artificial test on indirection shows that indirection is slower than no indirection by a significant amount. A bit pointless imo. It would be more interesting to talk about maintainability, flexibility and overhead when avoiding this kind of indirection inside hot loops but allowing it outside, in 'management' code.