On 14-Jan-2011, at 7:25 PM, Tito Ciuro wrote:

> Hi Mike,
> 
> Given that the caller can pass a NSDictionary or an NSMutableDictionary, I 
> wanted to test its mutability before calling setObject:forKey:. In order to 
> avoid calling mutableCopy each time, I thought it would be more efficient to 
> test it and then call mutableCopy only when needed.
> 
> Thanks for the help,
> 
> -- Tito
> 

remember - write it first, optimize it later. If your app is slow and you run 
the performance tools on it and making mutable copies is what's causing you 
performance issues then by all means optimize it at that point. My suspicion 
would be that making mutable copies of existing dictionaries is a pretty fast 
operation, apple's pretty good at that stuff. 

One other idea, if your method wants a dictionary it can mutate, how about 
making that the signature and making it up to the caller to send something 
mutable, as it seems not entirely unlikely the caller knows what it has. 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to