since my game engine performances doesn't satisfy me yet, I try to optimmize it.
I'm studying my code to identify algorithmics problems (such as collision tested twice, or innefficient data types).
Then come the C optimizations. I've read some articles on the subject, all with valuable tricks, but I've a lot of questions about them. So I'll ask those in this thread, and I start by some little things (there should be more in the future) :
1) is inline keyword useful ? For code clarity, I have some functions that are very simple and short, and it'd be more efficient to inline them. I thought the compiler would do it automatically but it doesn't seem to be the case. Should I declare these functions as inline, or must I use macros ?
2) is register keyword useful ? then again, sometimes the compiler doesn't use register for local variables.
3) I have many code that look like this :
Code: Select all
void my_function() {
if (condition) {
// do some stuff
}
}
// some code
my_function();
Code: Select all
void my_function() {
// do some stuff
}
// some code
if (condition) my_function();