Computed gotos on Reddit

Dmitry Olshansky dmitry.olsh at gmail.com
Thu Jul 26 13:52:09 PDT 2012


On 27-Jul-12 00:38, Walter Bright wrote:
> On 7/26/2012 8:55 AM, Dmitry Olshansky wrote:
>>> int test(int i)
>>> {
>>>      switch (i)
>>>      {
>>>          case 3: i += 3; break;
>>>          case 4: i += 4; break;
>>>          case 5: i += 5; break;
>>>          case 6: i += 6; break;
>>>          case 7: i += 7; break;
>>>          case 8: i += 8; break;
>>>          default: i += 100; break;
>>>      }
>>>      return i;
>>> }
>>>
>>
>> Do the above in loop. And more cases of course. Something around 40
>> should do.
>
>
> Here's my entire test program. It runs a consistent 5 to 10% slower with
> the new method compared with the old. Color me very disappointed.

Thanks. I'll play with it a bit if time permits.



-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list