News for hackers. Stuff that matters.
Re:In C++, is empty() faster than comparing the size with zero? by pansa2 on Thursday October 28, 2021 @05:28PM (#29032260)
On the other hand, if you’re not at the point where you care about maximum performance, you may want to shy away from C++ altogether.

This implies that there are very few situations in which C++ with STL is the right choice - which seems contrary to how widely it’s actually used.

Re:In C++, is empty() faster than comparing the size with zero? by Remnant44 on Thursday October 28, 2021 @09:26PM (#29034181)
This seems like a pretty silly way to look at performance - If I'm working in C++, I 'care' about performance, but performance always exists on a continuum.

If I "truly cared" I could write it in assembler; but I don't, because chasing down the diminishing returns isn't worth it.

C++ w/STD is a perfectly valid (and extremely powerful!) point in the continuum that runs from Python to Assembly :)

Re:In C++, is empty() faster than comparing the size with zero? by loup-vaillant on Thursday October 28, 2021 @08:05PM (#29033668)
Hmm, I’m not sure I agree there. There’s a difference between using C++ because I just want to avoid obvious waste (interpreter, GC pauses…), and actually optimizing my code.

I would put v.empty() vs v.size()==0 in the latter category. Day to day, I mostly trust that std::vector is not wasting cycles except on resizes.