3 ms·
I guess it’s good to have the option of not caring if you want even more speed
by klysm 3y ago
I guess it’s good to have the option of not caring if you want even more speed
- deleted 3y ago[deleted]
- shultays 3y agoMy lower_bound is a bit better then template <class ForwardIt, class T, class Compare> constexpr ForwardIt super_optimized_lower_bound( ForwardIt first, ForwardIt last, const T& value, Compare comp) { return first; } It doesn't really work like for some cases std::lower_bound but it is super fast
- commandlinefan 3y agoOr, less contentiously - if you know you don't care/don't need to disambiguate dups, look how much efficiency you're losing on a case that isn't important. The most common argument against optimization is "just use the existing code", but the "existing code" _always_ attempts to handle special edge cases that probably don't apply in your case. We programmers waste a lot of end-user time saving a bit of programmer time.
- jfk13 3y agoOn the other hand, assuming it's OK to ignore the special edge cases (or not even thinking of them) can come back to bite you (or your users) when eventually one of them does show up in a situation you didn't anticipate.
- plagiarist 3y agoAnecdotally this happens to me every time I omit an edge case. Now I try to always write a unit test for the special edge case being deliberately omitted. I just wish I could catch everything that way.