On May 28, 2013, at 12:38 AM, Oleg Krupnov <[email protected]> wrote:
> I just made the following experiment: > > I specified a hash method for my NSMapTable, but it always returns 0. > This seems to force the NSMapGet to always use key comparison for > searching for elements, as hash is always "not unique". > > Is this a good idea? If you're going to do that, why bother with an NSMapTable at all? Just store your pointers in a C array. > > Let me think. The keys are quite short strings, like 5-10 chars. How about making your hash function just return the first character casted to int? > > If we take the expense of calculating hash once for each search, then > comparing hash values is very quick, plus a few string comparisons in > the end if hash is not unique It's not useful to pursue this line of thinking without benchmarks. --Kyle Sluder _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
