Chapter 14 is twenty-four carat gold. Would love to see optimize.com as a dedicated site with Rosetta Code-style ports of optimization recipes across languages, platforms ;)
Quick link to grab all five manuals:
Quick link to grab all five manuals:
Maybe, but the bounds-checking optimisation [14.2] just looks dangerous. If you end up with an erroneous 'int' index of -1 then the original code will error out, whereas the new code will interpret it as 2^32 - 1. This is a perfectly valid index in an array of 2^32 values. This optimisation just isn't equivalent if INT_MAX < size <= UINT_MAX.
Am I missing something?
My point is, if size is dynamic, this is a dangerous optimisation.