enormego / cocoa-helpers

A collection of helpers (categories) we've written for iOS and OS X, full with convenience methods to make them easier and more useful. [tags:cocoa,objective-c,ios,mac]
http://developers.enormego.com
746 stars 74 forks source link

Inefficient [NSDictionary containsObjectForKey:] method #5

Open nicklockwood opened 13 years ago

nicklockwood commented 13 years ago

Searching the allKeys array will have linear performance degradation with the size of the dictionary since it has to check each item in the array sequentially - checking if [dictionary objectForKey:key] == nil has constant time performance regardless of array size and would be a much better implementation.