Reply to post: SWAP

You've seen things people wouldn't believe – so tell us your programming horrors

Frumious Bandersnatch

SWAP

Obviously better written something like:

int times = (loop +7) >> 3; // number of loops, rounded up

unsigned offset = loop & 7; // remainder div 8

switch(offset) {

case 0: do { SWAP;

case 7: SWAP;

case 6: SWAP;

case 5: SWAP;

case 4: SWAP;

case 3: SWAP;

case 2: SWAP;

case 1: SWAP;

} while (--times > 0);

}

Much clearer, surely :)

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon