That's quite a handy optimisation from gcc - I only dabble in C++ so maybe it would be obvious to someone that uses it day to day, but I had a good look at that code and couldn't see any obvious way to make is_empty O(1) based on its implementation.
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.
6 comments
[ 0.63 ms ] story [ 15.9 ms ] thread