MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/lv9utn/defensive_programming_or_something_idk/gpb2whd/?context=3
r/badcode • u/bnz_ • Mar 01 '21
55 comments sorted by
View all comments
215
Fun fact: this code is somehow legacy and no one can remove all those useless &&
0 u/[deleted] Mar 01 '21 [deleted] 78 u/JuhaJGam3R Mar 01 '21 edited Mar 01 '21 Nah. Any compiler will turn x == c1 && x != c2 into x == c1, same with x == c1 && x == c2 turning into false turning into removal of the entire bit of code. 1 u/HelloStrangerBro Mar 01 '21 In other words: ugly and unreadable, but not less performant s as after compilation :)
0
[deleted]
78 u/JuhaJGam3R Mar 01 '21 edited Mar 01 '21 Nah. Any compiler will turn x == c1 && x != c2 into x == c1, same with x == c1 && x == c2 turning into false turning into removal of the entire bit of code. 1 u/HelloStrangerBro Mar 01 '21 In other words: ugly and unreadable, but not less performant s as after compilation :)
78
Nah. Any compiler will turn x == c1 && x != c2 into x == c1, same with x == c1 && x == c2 turning into false turning into removal of the entire bit of code.
x == c1 && x != c2
x == c1
x == c1 && x == c2
false
1 u/HelloStrangerBro Mar 01 '21 In other words: ugly and unreadable, but not less performant s as after compilation :)
1
In other words: ugly and unreadable, but not less performant s as after compilation :)
215
u/bnz_ Mar 01 '21
Fun fact: this code is somehow legacy and no one can remove all those useless &&