Efficiency Question (really: nitpicking)

Lars Wirzenius wirzenius at cc.helsinki.fi
Wed Feb 27 12:16:13 AEST 1991


I won't answer your question, since that has already been answered by 
more knowledgeable people than I, but I just wanted to point out two
mistakes in your examples (at least one of which is a typo, I'm sure,
but nevertheless):

In article <4bmBqau00Uh_M0aHgb at andrew.cmu.edu>, rg2c+ at andrew.cmu.edu (Robert Nelson Gasch) writes:
[code edited for brevity]
>    if (x > y) z = x;
>    else       x = y;
> The same thing can be expressed like this:
>    z = (x > y) ? x : y;

..assuming you really meant "else z = y;" in the first version.

>    x++;
>    while (array[x] < max) do_this ();
> which can be written as:
>    while (array[++x] < max) do_this ();

This is not true, since the first version of the loop doesn't increment
i at all.
-- 
Lars "Nitpicking is fun" Wirzenius    wirzenius at cc.helsinki.fi



More information about the Comp.lang.c mailing list