TLIndexPathTools
TLIndexPathTools copied to clipboard
Non-ideal hash calculation
I think you want to replace += by = here:
https://github.com/SwiftKickMobile/TLIndexPathTools/blob/ca47649036081ec5b1220926ae072dab908301ea/TLIndexPathTools/Data%20Model/TLIndexPathItem.m#L53-57
Right now, you're effectively calculating:
hash = 32 * hash + [self.identifier hash];
Not sure I follow you. The initial value is hash = 0, so
hash += 31 * hash + [self.identifier hash];
is equivalent to
hash = [self.identifier hash];
and I'm not sure how that is non-ideal.
You're right for line 53 which could be simplified with line 52 to:
NSInteger hash = [self.identifier hash];
The issue is in lines 54 (and 55, 57):
hash += 31 * hash + [self.sectionName hash];
is equivalent to
hash = 32 * hash + [self.sectionName hash];
Ah, yeah. Oops