Re: NSRectArray by reference
Re: NSRectArray by reference
- Subject: Re: NSRectArray by reference
- From: Uli Kusterer <email@hidden>
- Date: Sun, 9 Sep 2007 21:25:22 +0200
On 09.09.2007, at 19:45, Keith Duncan wrote:
NS_INLINE void CalendarRowRects(NSRect calendarRect, NSUInteger
rows, NSRectArray *rowRects) {
Oh, and by the way: If you have problems with by-reference passing,
you shouldn't be playing with keywords like NS_INLINE. Inlining is a
performance optimization that causes the function body to be "copied
in" wherever it is called, instead of having one central function and
jumping to that and back. In most cases, what it actually causes to
happen is that the size of your program unnecessarily grows in size
(because you have dozens of copies of the same function instead of
just one), and that in turn will make your app use more RAM, and will
cause parts of it to be swapped to disk and read from disk again. And
when your app swaps, it's a much bigger performance drain than
function call overhead.
In summary: Don't use inlining unless you know what it does, and
run your application in the profiler (Shark) and determine whether
function call overhead is really what's slowing things down.
Generally, a function with a loop in it will be called rarely and
will spend most of its time in its loop, so inlining won't help.
Generally, mostly small functions benefit from inlining, and here
small usually implies no other function calls.
In general the rule is: Profile first, and then optimize the places
you spend the most time in. And that's generally functions you call
repeatedly. What use is it shaving a billionth of a second off a
function that is called only once over the life of your application?
Nobody will ever notice.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden