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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to