Inline function and calling cost in C

Posted by Eonil on Stack Overflow See other posts from Stack Overflow or by Eonil
Published on 2010-05-01T13:39:51Z Indexed on 2010/05/01 13:47 UTC
Read the original article Hit count: 204

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about c

    Related posts about inline-functions