Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
htk
· 5y ago · 0 comments
Why is is_empty comparing to bigger than zero instead of equals?
Comments
[–]
jb1991
5y ago
That’s a common optimization, not just with this particular requirement. Choose the thing that is most ambiguous that gives you the answer you need, and it’s more likely to result in a simpler hardware instruction.
[–]
rafaelvasco
5y ago
Probably because , for this case, comparing for > or < is faster than equality comparison. Which from my experience is true.
[–]
htk
OP
5y ago
The author edited the article and corrected is_empty to is_not_empty.