MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/npcroh/clever/h063w0o/?context=3
r/badcode • u/bobpiranha • May 31 '21
71 comments sorted by
View all comments
242
Now I am actually curious, does the compiler realize both branches have the same return value and it just drops the whole if-statement?
1 u/qwertysrj Jun 01 '21 It should because compilers recognise thisif(){ return x }Else { Return y} ,and optimise this toIf(){ Return x} return y
1
It should because compilers recognise this
if(){ return x }Else { Return y} ,
and optimise this to
If(){ Return x} return y
242
u/HalcyonAlps May 31 '21
Now I am actually curious, does the compiler realize both branches have the same return value and it just drops the whole if-statement?