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
-
Azer0s3036y@virustark24 yeah, it's pretty cool actually! It's basically a form of constant propagation because the compiler knows that
A: the function returns 3
And
B: the function doesn't make any calls to other functions
Afaik javac does not provide any option to prevent this optimization. It doesn't really matter for java, as javac keeps the method signature for reflection sake.
GCC on the other hand allows the prevention of constant folding/propagation! With the flag -flto you can disable LinkTimeOptimization. Idk why you'd need it but I think it's pretty cool! -
rant1ng44576y@virustark24 yeah but.. These days do we really have to worry that much about tiny optimizations unless we are Facebook or Twitter.
Even then..
You get shit ton traffic then you have money. Buy a decent server, no? -
Azer0s3036y@virustark24 that is a sensible thing to do...but the general consensus is that no one is as good as gcc -O3
-
This won't even return 3 from another function. You will have to write return returnthree()
-
ebroda1846yMaybe you wanted to avoid magic numbers, so a function improves that even if this one didn't ;)
-
It dawns on me drunk you did not only write such a function for the number three....
-
dmoa4186yprivate int getthree(int number) {
if (number == 3) {
return number;
} else {
return 3;
}
}
//fixed your drunk code!
Related Rants
Drunk me coding.
Next day: WTF, dude…?
joke/meme
coding
meme
java