Re:"When I design software, I really try hard to make it sim...
by dchest on Sunday September 25, 2011 @05:33PM
(#3036791)
Those 11 lines of reimplemented bsearch are correct.
Re:"When I design software, I really try hard to make it sim...
by wrs on Sunday September 25, 2011 @07:22PM
(#3037026)
Oh, I'm sure they are, purely based on who wrote them...but in any ordinary codebase I'd toss this code out in a second and replace it with a library call. It's just not worth the effort to decide whether it's correct -- like not bothering to bend over to pick up a lost penny.
Though it sounds simple, binary search is a minefield of edge cases and I've seen textbooks that do it wrong.
So when I read the GetMimeType function, I didn't think "how nice and simple"...I thought "Hmm, I bet that doesn't work."