Created
April 10, 2012 16:23
-
-
Save jfro/2352594 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/Classes/IRC/IRCUser.m b/Classes/IRC/IRCUser.m | |
| index 6ee00c8..59c2f45 100755 | |
| --- a/Classes/IRC/IRCUser.m | |
| +++ b/Classes/IRC/IRCUser.m | |
| @@ -4,6 +4,69 @@ | |
| #define COLOR_NUMBER_MAX 30 | |
| +#define hashsize(n) ( 1U << (n) ) | |
| +#define hashmask(n) ( hashsize ( n ) - 1 ) | |
| + | |
| +#define mix(a,b,c) \ | |
| +{ \ | |
| +a -= b; a -= c; a ^= ( c >> 13 ); \ | |
| +b -= c; b -= a; b ^= ( a << 8 ); \ | |
| +c -= a; c -= b; c ^= ( b >> 13 ); \ | |
| +a -= b; a -= c; a ^= ( c >> 12 ); \ | |
| +b -= c; b -= a; b ^= ( a << 16 ); \ | |
| +c -= a; c -= b; c ^= ( b >> 5 ); \ | |
| +a -= b; a -= c; a ^= ( c >> 3 ); \ | |
| +b -= c; b -= a; b ^= ( a << 10 ); \ | |
| +c -= a; c -= b; c ^= ( b >> 15 ); \ | |
| +} | |
| + | |
| +unsigned jen_hash ( const char *k, unsigned length, unsigned initval ) | |
| +{ | |
| + unsigned a, b; | |
| + unsigned c = initval; | |
| + unsigned len = length; | |
| + | |
| + a = b = 0x9e3779b9; | |
| + | |
| + while ( len >= 12 ) { | |
| + a += ( k[0] + ( (unsigned)k[1] << 8 ) | |
| + + ( (unsigned)k[2] << 16 ) | |
| + + ( (unsigned)k[3] << 24 ) ); | |
| + b += ( k[4] + ( (unsigned)k[5] << 8 ) | |
| + + ( (unsigned)k[6] << 16 ) | |
| + + ( (unsigned)k[7] << 24 ) ); | |
| + c += ( k[8] + ( (unsigned)k[9] << 8 ) | |
| + + ( (unsigned)k[10] << 16 ) | |
| + + ( (unsigned)k[11] << 24 ) ); | |
| + | |
| + mix ( a, b, c ); | |
| + | |
| + k += 12; | |
| + len -= 12; | |
| + } | |
| + | |
| + c += length; | |
| + | |
| + switch ( len ) { | |
| + case 11: c += ( (unsigned)k[10] << 24 ); | |
| + case 10: c += ( (unsigned)k[9] << 16 ); | |
| + case 9 : c += ( (unsigned)k[8] << 8 ); | |
| + /* First byte of c reserved for length */ | |
| + case 8 : b += ( (unsigned)k[7] << 24 ); | |
| + case 7 : b += ( (unsigned)k[6] << 16 ); | |
| + case 6 : b += ( (unsigned)k[5] << 8 ); | |
| + case 5 : b += k[4]; | |
| + case 4 : a += ( (unsigned)k[3] << 24 ); | |
| + case 3 : a += ( (unsigned)k[2] << 16 ); | |
| + case 2 : a += ( (unsigned)k[1] << 8 ); | |
| + case 1 : a += k[0]; | |
| + } | |
| + | |
| + mix ( a, b, c ); | |
| + | |
| + return c; | |
| +} | |
| + | |
| @interface IRCUser (Private) | |
| - (void)decayConversation; | |
| @end | |
| @@ -86,11 +149,12 @@ | |
| - (NSInteger)colorNumber | |
| { | |
| if (colorNumber < 0) { | |
| - if ([_NSUserDefaults() boolForKey:@"UUIDBasedNicknameColorHashing"]) { | |
| - colorNumber = (CFHash([NSString stringWithUUID]) % COLOR_NUMBER_MAX); | |
| - } else { | |
| - colorNumber = (CFHash([nick lowercaseString]) % COLOR_NUMBER_MAX); | |
| - } | |
| +// if ([_NSUserDefaults() boolForKey:@"UUIDBasedNicknameColorHashing"]) { | |
| +// colorNumber = (CFHash([NSString stringWithUUID]) % COLOR_NUMBER_MAX); | |
| +// } else { | |
| +// colorNumber = (CFHash([nick lowercaseString]) % COLOR_NUMBER_MAX); | |
| +// } | |
| + colorNumber = jen_hash([[nick lowercaseString] UTF8String], [nick length], 0) % COLOR_NUMBER_MAX; | |
| } | |
| return colorNumber; | |
| diff --git a/Resources/Miscellaneous/Info.plist b/Resources/Miscellaneous/Info.plist | |
| index 9991b14..608cb39 100755 | |
| --- a/Resources/Miscellaneous/Info.plist | |
| +++ b/Resources/Miscellaneous/Info.plist | |
| @@ -3,9 +3,9 @@ | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Build Number</key> | |
| - <string>9838</string> | |
| + <string>9842</string> | |
| <key>Build Reference</key> | |
| - <string>2.1.1-45-g24d90a6-stdbuild</string> | |
| + <string>2.1.1-49-g7a34bce-stdbuild</string> | |
| <key>CFBundleExecutable</key> | |
| <string>Textual</string> | |
| <key>CFBundleIconFile</key> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment