Is checking -count worth it?
Is checking -count worth it?
- Subject: Is checking -count worth it?
- From: Steve Cronin <email@hidden>
- Date: Wed, 23 Jul 2008 23:15:57 -0500
Folks;
I'm really trying to learn how to write smart fast code.
Code that takes maximum advantage of all of the battle-tested
intelligence built into Cocoa/ObjC2.
Now days with the "halo" and the "JesusPhone", I personally smell an
excellent book opportunity... But enough chit-chat.
I have a mutable array, M. I want to remove an object, O, from M; O
might not be in M.
M which is being constantly diminished could become empty.
Is this code worth it?
if ([M count]>0) [M removeObject:O];
OR should I just do
[M remove O];
I assume that I can't write better code than the removeObject's use of
-indexOfObject to determine the existence/location of O.
So there I get 'best performance' for free by just getting out of the
way and letting Cocoa do its thing.
Is the only way to really tell to test?
Or is there a deeper insight that makes the choice clear?
Steve
_______________________________________________
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