Live data from Hacker News

How We Beat C++ STL Binary Search

realm.io

51–52 of 52 posts

Re: How We Beat C++ STL Binary Search

#51
post #50

Earlier quoted context omitted.

Actually it is misleading by them( and you ) to assume that in C, an unsigned int can represent values larger than the largest signed int value. In other words, C allows that UINT_MAX == INT_MAX, in which case you will overflow. If they made that assumption, they should explicitly mention it, but they didn't. > Update 17 Feb 2008:... ...Now that we've made this change, we know that the program is correct;) It seems t…

Sure, and if you expect your software to run on such a platform with any degree of confidence then you're right to consider it. Even better, tell us about a conforming implementation that you've used in product recently that has UINT_MAX == INT_MAX. Also I'm not trying to mislead people into thinking that its a good way to implement this. The confounding bit from the article is they started in Java and ended up in C.…

You got it backwards there. Only if you know your implementation and plan to code only for it, can you even start to consider bending the C Standard, and not the other way around.

Re: How We Beat C++ STL Binary Search

#52
I think it's at the very least been hinted at below (and there are other good points), but note that their implementation makes copies. If the copy ctor of type T is the least bit expensive, the STL (implementation in glibc) for this same benchmark is far faster than theirs. Try it. :)
Post reply on HN