Original Post
I''m trying to get my rendering code to go as fast as possible, and i was wondering if anybody has tips on how to optimise my code or an article would be cool
Basically i''ve got a few functions that are getting called about 125 000 times per frame. Should i be doing things like using "inline" and "static"? i''m not sure what exactly they do and when i should be using them.
I noticed i jumped from about 100 fps to 300 fps by changing from something like this (its just an example):
for(int i=0; i<125000; i++)
{
MyFunction(i);
}
void MyFunction
{
if (!m_pArray)
return;
... rest of my code ...
}
to
for(int i=0; i<125000; i++)
{
if (m_pArray[i])
MyFunction(i);
}
void MyFunction
{
... code ...
}
I had a lot of empty spaces in my array, so that part of code was getting called a lot...
Anyway, this leads me to beleive that it is more efficient to bunch all my code in the loop rather than calling other functions... This seems rather messy though, is there something i can do here to speed it up (i.e. without cut and pasting my function into the loop)?
Allocating new memory also seems to be very slow, i noticed that using a fixed size array was much faster than using a linked list (although i really need the ability to dynamically change the size of my data :/).
Thanks.