Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C programming tricks

Name: Anonymous 2007-09-15 22:06 ID:WCtjqT0N

While programming optimization that makes ones' code completely unreadable is often a bad thing, there are places for it, like that one inner loop of your code that takes up 98% of the program's running time.

What are you tricks for improving performance in C, other than the obvious inline assembly or the like?

Name: Anonymous 2008-01-08 20:16

>>125
More precisely:

6.5p2
Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression.  Furthermore, the prior value shall be read only to determine the value to be stored.

In the expression *s=f[random()%2](*s++), s has its value modified and its prior value read to determine the new value:

*s=f[random()%2](*s++)
                  ^^^
but its prior value is also read elsewhere:
*s=f[random()%2](*s++)
 ^

which violates the second sentence of the quoted paragraph.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List