Re:John Carmack on Inlined Code (2014)
by m0zg on Tuesday January 22, 2019 @04:01AM
(#18967005)
Where did I say anything about relying on anything "indiscriminately"? Avoiding repetition at all cost is definitely a mistake. Avoiding repetition where it's justifiable could be a sensible choice. Though in your case I'd just say:
and be done with it.
[ Parent
| on HN ]
>Where did I say anything about relying on anything "indiscriminately"?
Well maybe I read a little too much into your comment but I interpreted it as "if you have small functions called only a small number of times in your code then you're a noob". I attempted to provide a counter-example.
I'm sure that you didn't mean it quite as literally but there probably are a bunch of young, inexperienced coders browsing this thread and I think these rules of thumb can be pretty counterproductive when they reach impressionable minds. Then you end up with people cargo-culting weird ad-hoc rules without even understanding the reasoning behind them.
>Avoiding repetition at all cost is definitely a mistake. Avoiding repetition where it's justifiable could be a sensible choice.
I completely agree on that.
#define machine_id() (readl(mgr->regs + OFF_MACHINE_ID) & 0xff)