Re: Cocoa and messages to nil, revisited
Re: Cocoa and messages to nil, revisited
- Subject: Re: Cocoa and messages to nil, revisited
- From: "Marc Wan" <email@hidden>
- Date: Wed, 8 Aug 2007 15:41:34 +0800
On 8/8/07, Jeff Laing <email@hidden> wrote:
>
> (As a performance junkie, its disappointing that people still think that its
> quicker to just send the message to nil, than to do "if (target) [target
> message];" since it doesn't matter *how* fast you make that message
> dispatcher, it can't possibly be faster than the two instructions that the
> conditional takes, especially since deep in its bowels we can see the
> message dispatcher doing the exact same test, but then taking a much longer
> execution path in either case)
it's probaby not long before we get yelled at for straying from
cocoa programming too much here, but as a pseudo-performance junkie
myself, who tries to balance this with code maintainability and
readability, it is VERY rare that i'm going to prefer
if (m_windowController) [m_windowController showWindowWithBase: window];
if (m_infoWindow) [m_infoWindow updateStatsForFile: currentFile];
if (m_fishfishfish) [m_fishfishfish takeTheBait: mooCow];
to:
[m_windowController showWindowWithBase: window];
[m_infoWindow updateStatsForFile: currentFile];
[m_fishfishfish takeTheBait: mooCow];
the latter is significantly more readable to me, and easier to surf
through in my code editor.
and i'll say somethng mildly provocative here: if your
application's performance is so borderline that the 50 (pulled that
number out of a hat) instructions (x 3, of course) that you're saving
on a 2GHz processor are so critical to your performance, you have way
more serious design issues that you should be focusing on.
90% of performance is good application design, in my opinion. but
then, i'm not writing high efficiency network routers, compilers, or
database servers. i'm just talkig "GUI apps" here.
YMMV, of course.
marc.
_______________________________________________
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