Sub-optimal boolean returns
See original GitHub issueInput:
function isTextInputElement(elem) {
if (!elem) {
return false;
}
if (elem.nodeName === 'INPUT') {
return !!supportedInputTypes[elem.type];
}
if (elem.nodeName === 'TEXTAREA') {
return true;
}
return false;
}
GCC Output:
function(a){return a?"INPUT"===a.nodeName?!!supportedInputTypes[a.type]:"TEXTAREA"===a.nodeName?!0:!1:!1}
Two things to be noted:
if (a === b) { return true; } return false;
is outputted asa === b ? !0 : !1
which can be simplified asa === b
, no need to do the condition.- all the return values have ! in common, it is possible to factor it out.
return !(a?"INPUT"===a.nodeName?!supportedInputTypes[a.type]:"TEXTAREA"===a.nodeName?0:1:1)
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
48297 – Suboptimal optimization of boolean expression addition
gcc does not seem to recognize that boolean expressions, such as (a==b), are at most 1. At least not when performing math on...
Read more >A* algorithm completes but returns suboptimal path
The algorithm: Uses a PQ that supports change priority operations. Assume all the ADTs work correctly. Example problem: Find the shortest path ...
Read more >IBM2804: suboptimal compares
A Boolean is a result of a comparison of two expressions or the result of anding, oring or negating Booleans. As such, a...
Read more >Comparing Hybrid Property to Boolean results in sub-optimal ...
Interesting, the suggestion that a boolean expression when compared to True should implicitly omit the True (and I suppose when compared to False...
Read more >EE364a Homework 5 solutions
We refer to this problem as the LP relaxation of the Boolean LP (4.67). The LP ... In scenario j, the return for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I modified the benchmark script a bit
Our output seems to be a little better now, but still not as good as closure: