Reputation: 126327
Will the typical compiler inline a C function that makes one or more Objective-C method calls? E.g.:
NSUInteger AACStringGetLength(NSString *string)
{
return [string length];
}
Bonus points for a thorough proof with explanation.
What other things besides recursion might prevent the compiler from inlining a C function?
Upvotes: 0
Views: 86
Reputation: 8012
AACStringGetLength()
can be inlined into its callers assuming the other requirements of inlining are satisfied. There's nothing about calls to Objective-C methods that prevents inlining of C functions.
Of course Objective-C methods cannot be inlined themselves, because the compiler cannot know that there is no unusual dynamic dispatch going on.
Things that can prevent inlining include:
Upvotes: 2