a style question
Steve Emmerson
steve at groucho.ucar.edu
Tue Oct 2 05:40:23 AEST 1990
In <12683:Oct102:57:1590 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu
(Dan Bernstein) writes:
>In article <8660 at ncar.ucar.edu> steve at groucho.ucar.edu (Steve Emmerson) writes:
>> # define NUM_ELEMENTS 100
>> for (x = 0; x < NUM_ELEMENTS; x++) ...
>Hmmm. I'll automatically write x = NUM_ELEMENTS; while (x--) ... for
>this kind of loop. On many computers it'll run noticeably faster, and I
>can safely replace NUM_ELEMENTS by a function call.
If the loop-body doesn't care, then I don't either. My point was the
use of a symbolic name rather than a hard-coded magic cookie (i.e.
NUM_ELEMENTS rather than "100").
Steve Emmerson steve at unidata.ucar.edu ...!ncar!unidata!steve
More information about the Comp.lang.c
mailing list