MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/npcroh/clever/h05pg3r/?context=9999
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?
100 u/[deleted] May 31 '21 Depends on whether or not the compiler is smart enough to realize that evaluating the conditional has no side-effects. Not sure what language this is 73 u/givemeagoodun May 31 '21 edited Jun 01 '21 It's flaired JS so it's JS 72 u/[deleted] May 31 '21 In that case the answer is an easy "no" since it's not a compiled language and there's no compiler 0 u/[deleted] Jun 01 '21 FireFox's SpiderMonkey and Chrome's V8 are both JITs and optimize at runtime. They would probably catch it.
100
Depends on whether or not the compiler is smart enough to realize that evaluating the conditional has no side-effects. Not sure what language this is
73 u/givemeagoodun May 31 '21 edited Jun 01 '21 It's flaired JS so it's JS 72 u/[deleted] May 31 '21 In that case the answer is an easy "no" since it's not a compiled language and there's no compiler 0 u/[deleted] Jun 01 '21 FireFox's SpiderMonkey and Chrome's V8 are both JITs and optimize at runtime. They would probably catch it.
73
It's flaired JS so it's JS
72 u/[deleted] May 31 '21 In that case the answer is an easy "no" since it's not a compiled language and there's no compiler 0 u/[deleted] Jun 01 '21 FireFox's SpiderMonkey and Chrome's V8 are both JITs and optimize at runtime. They would probably catch it.
72
In that case the answer is an easy "no" since it's not a compiled language and there's no compiler
0 u/[deleted] Jun 01 '21 FireFox's SpiderMonkey and Chrome's V8 are both JITs and optimize at runtime. They would probably catch it.
0
FireFox's SpiderMonkey and Chrome's V8 are both JITs and optimize at runtime. They would probably catch it.
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?