Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Optimizing C code for speed

Author: Daniel Clausen

Date: 14:46:26 01/02/03

Go up one level in this thread



On January 02, 2003 at 16:52:12, Dieter Buerssner wrote:

[snip]

>Also, most probably this function will never be called with len 0. Then a do
>while loop would be appropriate:
>
>int add_them(int *dest, int *src1, int *src2, size_t len)
>{
>    /* Perhaps, for some compiler, using a local variable for len may help */
>    do
>    {
>        *dest++ = *src1++ + *src2++;
>    } while (--len != 0);
>}

And that's a good example where I would insert an "assert(len != 0);", althought
it's completely useless, because it never will be called with len==0 anyway. :)

Murph^H^H^H^H^Sargon



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.