Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
Or make it static so that the compiler can inline it. Making it a macro could already blow up the way it is written, and even if that were adapted to macro usage, it could still cost performance.
Btw., the "devrant" tag does not mean "developer rant". There are only devs here, so every rant is obviously a developer rant. No finance, HR, or sales folks rant. "devrant" is for stuff about devrant.com itself.
Yadda yadda, devrant tags actually for devrant.io devrant.com and devrant app only.
As for your question, throw a inline there and call it a PR.
KDSBest7361yIf it is not in a class, the compiler should inline it. So this isn't too bad.
(I hope that I got the point, so..)
When I was learning code I was taught to make some methods as smaller as possible like this to be easier to read and make it possible to be reused:
return a * 100
Later I learned about the cost of functions, but also that the compiler can optimize it, making something like the inline and the static.
Anyway, if I'm going to use this calculate function a lot of times, even if the compiler isn't going to optimize it and it is not a big cost, then I prefer to write that small function to make it easier to maintain
@melezorus34 yes, and no. I work with Android then I need to presume that the user has a limit amount of resources, but I know that the compiler can lead well with that kind of methods, then I do it a lot when I'm coding for it. When I'm coding games or others stuffs I generally don't do it