logoalt Hacker News

pcthrowawaylast Friday at 11:37 PM1 replyview on HN

Wouldn't using elif for all comparisons after the first improve performance?

Or is the performance considered worse because it becomes O(n) (where n < MAX_UINT) vs. constant time ( O(MAX_UINT) )


Replies

billforsternzlast Saturday at 12:45 AM

It certainly would be normal to use else if (or switch) if you wanted to be picky but really such changes are inconsequential here. And I was trying to change just one line. Sadly I also had to quietly change stdlib.h to string.h as well.