POV-Ray : Newsgroups : povray.unofficial.patches : Poly is slower in megapov than in the official pov? : Re: Poly is slower in megapov than in the official pov? Server Time
2 Sep 2024 10:13:06 EDT (-0400)
  Re: Poly is slower in megapov than in the official pov?  
From: Thorsten Froehlich
Date: 15 Feb 2000 09:57:08
Message: <38a96944@news.povray.org>
In article <38a91600@news.povray.org> , Nieminen Juha 
<war### [at] sarakerttunencstutfi>  wrote:

>   I don't know how the compiler handles those switch constructs, but if the
> item to be selected is an integer type, I can't think of anything but a
> bunch of if...else if...else if... structures. This, of course, is rather
> slow when there is a considerable amount of cases.

No, usually it is done by a jump table (if the case variables are close and
not distributed over the whole range of integers - a long story :-)  ).  You
can then have a constant time to perform the switch-case.  Just thing of it
as and array of function points (not exactly the same, but close enough to
get the idea):

switch(i)
{
    case 1:
        // .....
        break;
    case 2:
        // .....
        break;
    case 3:
        // .....
        break;
    default:
        // .....
        break;
}

int (*casefunc)()[3];

if(i < 0 || i > 2)
    // default
else
    // case casefunc[i]()



       Thorsten



____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.