> Only thing that makes it still slower than I want it, is the iteration that
> occurs most of the time to find a free particle in the array. Just think of
> _not_ doing it this way:
>
> for (int i=0;i<MAX_PARTICLES;i++)
> {
>         if ( !m_pMyArray[i]->bInUse )
>                 return &m_pMyArray[i];
> }

Why not also keep a "free" list...

void *GetFreeParticle(void)
{
   void *p;

   p = free_head;
   free_head = p->next;
   return p;
}

void FreeParticle(void *p)
{
   free_tail->next = p;
   free_tail = p;
}

...much faster.

P.S. Please learn to chop off the non-relevant text in the posts you are
replying to.  Thanks!

Jeffrey "botman" Broome

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to