Wednesday, March 3, 2010

Switch и fall-through



Интересное использование switch:

register n = (count + 7) / 8;
switch (count % 8)
{
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 (--n > 0);
}

4 comments:

  1. http://en.wikipedia.org/wiki/Duff's_device

    ReplyDelete
  2. http://www.cs.virginia.edu/stream/FTP/Contrib/AMD/memcpy_amd.cpp

    ReplyDelete