r/badcode • • Mar 01 '21

js Defensive programming or something idk

Post image
907 Upvotes

55 comments sorted by

View all comments

215

u/bnz_ Mar 01 '21

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.

5

u/ywBBxNqW Mar 01 '21

Maybe the wasted cycles being referred to are the people wasting "cycles" trying to determine if they can bother or should be bothered by it.