changeset 10099:c49cc5b818cf

[gaim-migrate @ 11122] Luke got me thinking of a better way to do screename coloring in chats. I came up with a two-step solution. This is step 1: use a decent hashing algorithm with much fewer collisions than the simple one I used. g_str_hash does the trick. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 14 Oct 2004 18:15:10 +0000
parents fb4216714dac
children fad5d3354cc1
files src/gtkconv.c
diffstat 1 files changed, 2 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkconv.c	Thu Oct 14 03:59:00 2004 +0000
+++ b/src/gtkconv.c	Thu Oct 14 18:15:10 2004 +0000
@@ -5224,17 +5224,8 @@
 				if (flags & GAIM_MESSAGE_NICK)
 					strcpy(color, "#AF7F00");
 				else if (flags & GAIM_MESSAGE_RECV) {
-					if (flags & GAIM_MESSAGE_COLORIZE) {
-						const char *u;
-						int m = 0;
-
-						for (u = who; *u != '\0'; u++)
-							m += *u;
-
-						m = m % NUM_NICK_COLORS;
-
-						strcpy(color, nick_colors[m]);
-					}
+					if (flags & GAIM_MESSAGE_COLORIZE) 
+						strcpy(color, g_str_hash(who) % NUM_NICK_COLORS);
 					else
 						strcpy(color, RECV_COLOR);
 				}