Robert Dewar <[EMAIL PROTECTED]> writes: > An optimziation is dubious to me if > > a) it produces surprising changes in behavior (note the importance of > the word surprising here) > > b) it does not provide significant performance gains (note the > importance of the word significant here). > > I find this optimization qualifies as meeting both criteria a) and b), > so that's why I consider it dubious.
To this particular optimization does not meet criteria a). I never write code that constructs a pointer which does not point to any object, because I know that is invalid. I think it is rather weird that anybody would write code like this. If I want to check whether an index is out of bounds, I compare the index and the length of the buffer. I don't use a pointer comparison to check for an out of bounds index. I don't know about criteria b), I haven't measured. It's easy to come up with test cases where it gives a performance gain--many loops with a pointer induction variable will benefit--but I don't know how significant they are. Ian