How I doubled the speed of my game by giving up on C++
chrismdp.com
chrismdp.com
When you are familiar with asm you see that `obj->virt_func()` not just fancy and convenient but also there are some magic behind that which cannot be described by simple `call mangled_virt_func_addr`.
When you are familiar with asm you can see than calling function like
int foo(int a, int b) {
return a + b;
}
is way slower than just do `a+b`, and not just because of call/ret instuctions and possible cache misses, but because of compiler lacks ability to make some optimisations. And you write `inline` functions for such small tasks.When you are familiar with asm you inevitable see all this quirks. Sometimes you do not want to see them, but nevertheless you notice them every time, and you need to make a consious decision to leave some code inefficient, due to (for example) "i'm writing program that will be run one or two times, and time spent to make it fast would be greater than time saved on faster program runs".
You are comparing apples and oranges.
Which is pretty remarkable actually. In favor of C++.
Why didn't the author rewrite it in C++? It's not like C can do anything that C++ can't.