Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
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. -
rittmann1053y(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:
function calculatevalue(a)
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 -
@rittmann sure there is a cost but are you working with a system with hard limits?
-
rittmann1053y@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
-
@rittmann well I can assure you it's negligible with current processors, so don't worry optimizing first, do the thing then optimize and refactor.
Part of the excuse of us never releasing our side-projects is perfectionism. -
rittmann1053y@melezorus34 I don't optimize first if it isn't required, but a like do optimize the code as possible as I can
Related Rants
When people write functions/methods with bodies smaller that the call header (-_- ).
Function calls are not free people! Just Inline that shit manually (or at least make sure the compiler does so)!
double degree_to_radians(double degree){
....return (degree / 180.0) * M_PI;
}
devrant
code bloat
function