Inline function and calling cost in C
- by Eonil
I'm making a vector/matrix library. (GCC, ARM NEON, iPhone)
typedef struct{ float v[4]; } Vector;
typedef struct{ Vector v[4]; } Matrix;
I passed struct data as pointer to avoid performance degrade from data copying when calling function. So I thought designed function like this:
void makeTranslation(const Vector* factor, Matrix* restrict result);
But, if function is inline, is there any reason to pass values as pointer for performance? Do those variables copied too? How about register and caches?
inline Matrix makeTranslation(Vector factor) __attribute__ ((always_inline));
How do you think about calling costs of each cases?