CG_INLINE
is a macro that is used to mark a method as an inline function. The exact syntax is (was ?) compiler dependent, and through preprocessor checks the correct one is chosen for your compiler.
For current GCCs, it should resolve to static inline
.
The point of a function marked with inline
is that the compiler may insert the equivalent of that function's body where the function was called, instead of making a (slightly more costly) function call. So if you have:
inline int foo(int a, int b)
{
return a + b;
}
void bar(int a, int b)
{
NSLog(@"%d", foo(a, b));
}
The compile then is allowed to internally transform it to:
void bar(int a, int b)
{
NSLog(@"%d", a + b);
}
This saves a function call which on some architectures might be costly and might be very noticeable for example when you're calling the function in a loop a few thousand times.
Note that it only means the compiler may do this transformation, it doesn't necessarily mean it does do it. Depends on compiler settings.