Re: Class.c

From: George Greer (
Date: 06/20/02

On Thu, 20 Jun 2002, Dante Mavec wrote:

>While poking around class.c I found a comment that implied that a huge set of switches like this:

What comment?

>etc etc etc is faster (processor-wise) than something like " return (100
>- (GET_LEVEL(ch) * 1.5)) "
>I'd be inclined to say that this isn't the case...  the second way of
>doing it is one calculation, whereas the latter could have to make 20 or
>so comparisions between GET_LEVEL(ch) and a number before finding the
>right value.

Of course it isn't.  The original array was much faster but since people
would tend to forget to adjust the array when they added levels, we made
them functions.

>Firstly, does the second actually use more juice?
>Secondly, if it does, is it an appreciable amount?

It does, but GCC does a fair job optimizing it.  It's not a linear search.

George Greer

   | FAQ: |
   | Archives: |
   | Newbie List:   |

This archive was generated by hypermail 2b30 : 06/25/03 PDT