Pointer arithmetic and comparisons.

Walter Bright bright at Data-IO.COM
Thu Dec 14 08:23:56 AEST 1989


In article <2908 at murtoa.cs.mu.oz.au> rob at murtoa.UUCP (Robert Wallen) writes:
<Now a beef.  Why check for (p <= pend)?  Why not just ( p == pend) ?
<After all,
<its not as though your code might accidentally skip over the last entry !!

(p <= pend) generates more efficient code (on PC's) than (p == pend), because
on the former only the offset portions of the pointer need to be compared,
while on the latter both the segment and the offset must be compared.



More information about the Comp.lang.c mailing list