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 2007-09-15 22:28 ID:/cLfUcQO

Don't use C, Use BBCode

Name: Anonymous 2007-09-15 23:50 ID:Heaven


switch (count % 8)  /* count > 0 assumed */
 {
   case 0:        do {  *to = *from++;
   case 7:              *to = *from++;
   case 6:              *to = *from++;
   case 5:              *to = *from++;
   case 4:              *to = *from++;
   case 3:              *to = *from++;
   case 2:              *to = *from++;
   case 1:              *to = *from++;
                     } while ((count -= 8) > 0);
 }

Name: Anonymous 2007-09-15 23:52 ID:Heaven

Swap two variables without temporary variable

*x ^= *y;*y ^= *x;*x ^= *y;

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