Click to See Complete Forum and Search --> : Identify this code block


Joe Nellis
May 15th, 2004, 10:47 AM
I saw this a couple years ago. It was discovered by an Aussie I think when he was trying to do something, maybe image processing. Anyway, it was named after him and I was wondering if anyone remembers it and what he used it for. I'm sure it's on google somewhere but I don't know what keywords to use. I want to say that it had something to do with matrix calculations but I'm not solid about that.


switch(val) {
case 0: while( notdone ) {
case 1: // do something
case 2: // do something
case 3: // do something
default: }
}

Sotek
May 15th, 2004, 07:32 PM
It's Duff's Device.

It's to unroll a hardware access loop to increase efficiency by cutting down on the number of jumps.


And you have it slightly off; you switch on a number mod another, then the loop is on the number divided by eight, then decremented by one per loop until it hits zero.

Joe Nellis
May 15th, 2004, 10:06 PM
Thanks.