r/badcode • • Sep 13 '20

c Found in git's bisect algorithm

Post image
744 Upvotes

17 comments sorted by

View all comments

25

u/caldazar24 Sep 14 '20

I doubt the actual function would belong here. First, what qualifies as “truly stupid” by the standards of the git codebase is probably far better than anything posted here. Second, from the comment I assume they think it’s stupid for performance reasons, but using a naive algorithm (that’s probably easier to follow along when reading than a more optimal one) in an area where you don’t care about performance is good code, especially if the decision is being made very deliberately!