Matthew Barnes ad2b69
--- evolution-2.9.1/mail/message-list.c.ememory	2006-10-25 11:11:34.000000000 -0400
Matthew Barnes ad2b69
+++ evolution-2.9.1/mail/message-list.c	2006-10-25 11:15:12.000000000 -0400
Matthew Barnes ad2b69
@@ -412,70 +412,28 @@
Matthew Barnes ad2b69
 	return info;
Matthew Barnes ad2b69
 }
Matthew Barnes ad2b69
 
Matthew Barnes ad2b69
-static const char *
Matthew Barnes ad2b69
-get_normalised_string (MessageList *message_list, CamelMessageInfo *info, int col)
Matthew Barnes ad2b69
+static const gchar *
Matthew Barnes ad2b69
+get_normalised_string (MessageList *message_list, const gchar *string)
Matthew Barnes ad2b69
 {
Matthew Barnes ad2b69
-	const char *string, *str;
Matthew Barnes ad2b69
-	char *normalised;
Matthew Barnes ad2b69
-	EPoolv *poolv;
Matthew Barnes ad2b69
-	int index;
Matthew Barnes ad2b69
-	
Matthew Barnes ad2b69
-	switch (col) {
Matthew Barnes ad2b69
-	case COL_SUBJECT_NORM:
Matthew Barnes ad2b69
-		string = camel_message_info_subject (info);
Matthew Barnes ad2b69
-		index = NORMALISED_SUBJECT;
Matthew Barnes ad2b69
-		break;
Matthew Barnes ad2b69
-	case COL_FROM_NORM:
Matthew Barnes ad2b69
-		string = camel_message_info_from (info);
Matthew Barnes ad2b69
-		index = NORMALISED_FROM;
Matthew Barnes ad2b69
-		break;
Matthew Barnes ad2b69
-	case COL_TO_NORM:
Matthew Barnes ad2b69
-		string = camel_message_info_to (info);
Matthew Barnes ad2b69
-		index = NORMALISED_TO;
Matthew Barnes ad2b69
-		break;
Matthew Barnes ad2b69
-	default:
Matthew Barnes ad2b69
-		string = NULL;
Matthew Barnes ad2b69
-		index = NORMALISED_LAST;
Matthew Barnes ad2b69
-		g_assert_not_reached ();
Matthew Barnes ad2b69
-	}
Matthew Barnes ad2b69
-	
Matthew Barnes ad2b69
-	/* slight optimisation */
Matthew Barnes ad2b69
-	if (string == NULL || string[0] == '\0')
Matthew Barnes ad2b69
+	GHashTable *hash_table = message_list->normalised_hash;
Matthew Barnes ad2b69
+	GStringChunk *string_chunk = message_list->string_chunk;
Matthew Barnes ad2b69
+	gchar *collation_key, *temp;
Matthew Barnes ad2b69
+
Matthew Barnes ad2b69
+	if (string == NULL || *string == '\0')
Matthew Barnes ad2b69
 		return "";
Matthew Barnes ad2b69
-	
Matthew Barnes ad2b69
-	poolv = g_hash_table_lookup (message_list->normalised_hash, camel_message_info_uid (info));
Matthew Barnes ad2b69
-	if (poolv == NULL) {
Matthew Barnes ad2b69
-		poolv = e_poolv_new (NORMALISED_LAST);
Matthew Barnes ad2b69
-		g_hash_table_insert (message_list->normalised_hash, (char *) camel_message_info_uid (info), poolv);
Matthew Barnes ad2b69
-	} else {
Matthew Barnes ad2b69
-		str = e_poolv_get (poolv, index);
Matthew Barnes ad2b69
-		if (*str)
Matthew Barnes ad2b69
-			return str;
Matthew Barnes ad2b69
-	}
Matthew Barnes ad2b69
-	
Matthew Barnes ad2b69
-	if (col == COL_SUBJECT_NORM) {
Matthew Barnes ad2b69
-		const unsigned char *subject;
Matthew Barnes ad2b69
-		
Matthew Barnes ad2b69
-		subject = (const unsigned char *) string;
Matthew Barnes ad2b69
-		while (!g_ascii_strncasecmp (subject, "Re:", 3)) {
Matthew Barnes ad2b69
-			subject += 3;
Matthew Barnes ad2b69
-			
Matthew Barnes ad2b69
-			/* jump over any spaces */
Matthew Barnes ad2b69
-			while (*subject && isspace ((int) *subject))
Matthew Barnes ad2b69
-				subject++;
Matthew Barnes ad2b69
-		}
Matthew Barnes ad2b69
-		
Matthew Barnes ad2b69
-		/* jump over any spaces */
Matthew Barnes ad2b69
-		while (*subject && isspace ((int) *subject))
Matthew Barnes ad2b69
-			subject++;
Matthew Barnes ad2b69
-		
Matthew Barnes ad2b69
-		string = (const char *) subject;
Matthew Barnes ad2b69
-	}
Matthew Barnes ad2b69
-	
Matthew Barnes ad2b69
-	normalised = g_utf8_collate_key (string, -1);
Matthew Barnes ad2b69
-	e_poolv_set (poolv, index, normalised, TRUE);
Matthew Barnes ad2b69
-	
Matthew Barnes ad2b69
-	return e_poolv_get (poolv, index);
Matthew Barnes ad2b69
+
Matthew Barnes ad2b69
+	collation_key = g_hash_table_lookup (hash_table, string);
Matthew Barnes ad2b69
+	if (collation_key != NULL)
Matthew Barnes ad2b69
+		return collation_key;
Matthew Barnes ad2b69
+
Matthew Barnes ad2b69
+	temp = g_utf8_collate_key (string, -1);
Matthew Barnes ad2b69
+	collation_key = g_string_chunk_insert_const (string_chunk, temp);
Matthew Barnes ad2b69
+	g_free (temp);
Matthew Barnes ad2b69
+
Matthew Barnes ad2b69
+	temp = g_string_chunk_insert_const (string_chunk, string);
Matthew Barnes ad2b69
+	g_hash_table_insert (hash_table, temp, collation_key);
Matthew Barnes ad2b69
+
Matthew Barnes ad2b69
+	return collation_key;
Matthew Barnes ad2b69
 }
Matthew Barnes ad2b69
 
Matthew Barnes ad2b69
 static void
Matthew Barnes ad2b69
@@ -1283,12 +1241,23 @@
Matthew Barnes ad2b69
 		str = camel_message_info_from (msg_info);
Matthew Barnes ad2b69
 		return (void *)(str ? str : "");
Matthew Barnes ad2b69
 	case COL_FROM_NORM:
Matthew Barnes ad2b69
-		return (void *) get_normalised_string (message_list, msg_info, col);
Matthew Barnes ad2b69
+		str = camel_message_info_from (msg_info);
Matthew Barnes ad2b69
+		return (void *) get_normalised_string (message_list, str);
Matthew Barnes ad2b69
 	case COL_SUBJECT:
Matthew Barnes ad2b69
 		str = camel_message_info_subject (msg_info);
Matthew Barnes ad2b69
 		return (void *)(str ? str : "");
Matthew Barnes ad2b69
 	case COL_SUBJECT_NORM:
Matthew Barnes ad2b69
-		return (void *) get_normalised_string (message_list, msg_info, col);
Matthew Barnes ad2b69
+		str = camel_message_info_subject (msg_info);
Matthew Barnes ad2b69
+		while (str != NULL && *str != '\0') {
Matthew Barnes ad2b69
+			/* skip over spaces and reply prefixes */
Matthew Barnes ad2b69
+			if (g_ascii_strncasecmp (str, "Re:", 3) == 0)
Matthew Barnes ad2b69
+				str += 3;
Matthew Barnes ad2b69
+			else if (g_ascii_isspace (*str))
Matthew Barnes ad2b69
+				str++;
Matthew Barnes ad2b69
+			else
Matthew Barnes ad2b69
+				break;
Matthew Barnes ad2b69
+		}
Matthew Barnes ad2b69
+		return (void *) get_normalised_string (message_list, str);
Matthew Barnes ad2b69
 	case COL_SENT: {
Matthew Barnes ad2b69
 		ETreePath child;
Matthew Barnes ad2b69
 
Matthew Barnes ad2b69
@@ -1312,7 +1281,8 @@
Matthew Barnes ad2b69
 		str = camel_message_info_to (msg_info);
Matthew Barnes ad2b69
 		return (void *)(str ? str : "");
Matthew Barnes ad2b69
 	case COL_TO_NORM:
Matthew Barnes ad2b69
-		return (void *) get_normalised_string (message_list, msg_info, col);
Matthew Barnes ad2b69
+		str = camel_message_info_to (str);
Matthew Barnes ad2b69
+		return (void *) get_normalised_string (message_list, str);
Matthew Barnes ad2b69
 	case COL_SIZE:
Matthew Barnes ad2b69
 		return GINT_TO_POINTER (camel_message_info_size(msg_info));
Matthew Barnes ad2b69
 	case COL_DELETED:
Matthew Barnes ad2b69
@@ -2023,9 +1993,10 @@
Matthew Barnes ad2b69
 	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (message_list), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
Matthew Barnes ad2b69
 	
Matthew Barnes ad2b69
 	message_list->normalised_hash = g_hash_table_new (g_str_hash, g_str_equal);
Matthew Barnes ad2b69
+	message_list->string_chunk = g_string_chunk_new (1024);
Matthew Barnes ad2b69
 	
Matthew Barnes ad2b69
 	message_list->hidden = NULL;
Matthew Barnes ad2b69
-	message_list->hidden_pool = NULL;
Matthew Barnes ad2b69
+	message_list->hidden_string_chunk = NULL;
Matthew Barnes ad2b69
 	message_list->hide_before = ML_HIDE_NONE_START;
Matthew Barnes ad2b69
 	message_list->hide_after = ML_HIDE_NONE_END;
Matthew Barnes ad2b69
 	
Matthew Barnes ad2b69
@@ -2054,14 +2025,6 @@
Matthew Barnes ad2b69
 	g_signal_connect (((GtkScrolledWindow *) message_list)->vscrollbar, "value-changed", G_CALLBACK (ml_scrolled), message_list);
Matthew Barnes ad2b69
 }
Matthew Barnes ad2b69
 
Matthew Barnes ad2b69
-static gboolean
Matthew Barnes ad2b69
-normalised_free (gpointer key, gpointer value, gpointer user_data)
Matthew Barnes ad2b69
-{
Matthew Barnes ad2b69
-	e_poolv_destroy (value);
Matthew Barnes ad2b69
-	
Matthew Barnes ad2b69
-	return TRUE;
Matthew Barnes ad2b69
-}
Matthew Barnes ad2b69
-
Matthew Barnes ad2b69
 static void
Matthew Barnes ad2b69
 message_list_destroy(GtkObject *object)
Matthew Barnes ad2b69
 {
Matthew Barnes ad2b69
@@ -2127,17 +2090,17 @@
Matthew Barnes ad2b69
 	MessageList *message_list = MESSAGE_LIST (object);
Matthew Barnes ad2b69
 	struct _MessageListPrivate *p = message_list->priv;
Matthew Barnes ad2b69
 	
Matthew Barnes ad2b69
-	g_hash_table_foreach (message_list->normalised_hash, (GHFunc) normalised_free, NULL);
Matthew Barnes ad2b69
 	g_hash_table_destroy (message_list->normalised_hash);
Matthew Barnes ad2b69
+	g_string_chunk_free (message_list->string_chunk);
Matthew Barnes ad2b69
 	
Matthew Barnes ad2b69
 	if (message_list->thread_tree)
Matthew Barnes ad2b69
 		camel_folder_thread_messages_unref(message_list->thread_tree);
Matthew Barnes ad2b69
 
Matthew Barnes ad2b69
 	if (message_list->hidden) {
Matthew Barnes ad2b69
 		g_hash_table_destroy(message_list->hidden);
Matthew Barnes ad2b69
-		e_mempool_destroy(message_list->hidden_pool);
Matthew Barnes ad2b69
+		g_string_chunk_free(message_list->hidden_string_chunk);
Matthew Barnes ad2b69
 		message_list->hidden = NULL;
Matthew Barnes ad2b69
-		message_list->hidden_pool = NULL;
Matthew Barnes ad2b69
+		message_list->hidden_string_chunk = NULL;
Matthew Barnes ad2b69
 	}
Matthew Barnes ad2b69
 
Matthew Barnes ad2b69
 	g_free(message_list->search);
Matthew Barnes ad2b69
@@ -2940,17 +2903,6 @@
Matthew Barnes ad2b69
 		d(printf("changed = %d added = %d removed = %d\n",
Matthew Barnes ad2b69
 			 changes->uid_changed->len, changes->uid_added->len, changes->uid_removed->len));
Matthew Barnes ad2b69
 		
Matthew Barnes ad2b69
-		for (i = 0; i < changes->uid_removed->len; i++) {
Matthew Barnes ad2b69
-			/* uncache the normalised strings for these uids */
Matthew Barnes ad2b69
-			EPoolv *poolv;
Matthew Barnes ad2b69
-			
Matthew Barnes ad2b69
-			poolv = g_hash_table_lookup (ml->normalised_hash, changes->uid_removed->pdata[i]);
Matthew Barnes ad2b69
-			if (poolv != NULL) {
Matthew Barnes ad2b69
-				g_hash_table_remove (ml->normalised_hash, changes->uid_removed->pdata[i]);
Matthew Barnes ad2b69
-				e_poolv_destroy (poolv);
Matthew Barnes ad2b69
-			}
Matthew Barnes ad2b69
-		}
Matthew Barnes ad2b69
-		
Matthew Barnes ad2b69
 		/* check if the hidden state has changed, if so modify accordingly, then regenerate */
Matthew Barnes ad2b69
 		if (ml->hidejunk || ml->hidedeleted)
Matthew Barnes ad2b69
 			mail_folder_hide_by_flag (folder, ml, &changes, (ml->hidejunk ? CAMEL_MESSAGE_JUNK : 0) | (ml->hidedeleted ? CAMEL_MESSAGE_DELETED : 0));
Matthew Barnes ad2b69
@@ -3028,7 +2980,11 @@
Matthew Barnes ad2b69
 	}
Matthew Barnes ad2b69
 	
Matthew Barnes ad2b69
 	/* reset the normalised sort performance hack */
Matthew Barnes ad2b69
-	g_hash_table_foreach_remove (message_list->normalised_hash, normalised_free, NULL);
Matthew Barnes ad2b69
+	/* XXX GLib 2.12 added g_hash_table_remove_all() */
Matthew Barnes ad2b69
+	g_hash_table_destroy (message_list->normalised_hash);
Matthew Barnes ad2b69
+	message_list->normalised_hash = g_hash_table_new (g_str_hash, g_str_equal);
Matthew Barnes ad2b69
+	g_string_chunk_free (message_list->string_chunk);
Matthew Barnes ad2b69
+	message_list->string_chunk = g_string_chunk_new (1024);
Matthew Barnes ad2b69
 	
Matthew Barnes ad2b69
 	mail_regen_cancel(message_list);
Matthew Barnes ad2b69
 	
Matthew Barnes ad2b69
@@ -3479,14 +3435,14 @@
Matthew Barnes ad2b69
 			MESSAGE_LIST_LOCK (ml, hide_lock);
Matthew Barnes ad2b69
 			if (ml->hidden == NULL) {
Matthew Barnes ad2b69
 				ml->hidden = g_hash_table_new (g_str_hash, g_str_equal);
Matthew Barnes ad2b69
-				ml->hidden_pool = e_mempool_new (512, 256, E_MEMPOOL_ALIGN_BYTE);
Matthew Barnes ad2b69
+				ml->hidden_string_chunk = g_string_chunk_new (512);
Matthew Barnes ad2b69
 			}
Matthew Barnes ad2b69
 			
Matthew Barnes ad2b69
-			uid =  e_mempool_strdup (ml->hidden_pool, uids->pdata[i]);
Matthew Barnes ad2b69
+			uid = g_string_chunk_insert (ml->hidden_string_chunk, uids->pdata[i]);
Matthew Barnes ad2b69
 			g_hash_table_insert (ml->hidden, uid, uid);
Matthew Barnes ad2b69
 			for ( ; i < uids->len; i++) {
Matthew Barnes ad2b69
 				if (g_hash_table_lookup (ml->uid_nodemap, uids->pdata[i])) {
Matthew Barnes ad2b69
-					uid =  e_mempool_strdup (ml->hidden_pool, uids->pdata[i]);
Matthew Barnes ad2b69
+					uid = g_string_chunk_insert (ml->hidden_string_chunk, uids->pdata[i]);
Matthew Barnes ad2b69
 					g_hash_table_insert (ml->hidden, uid, uid);
Matthew Barnes ad2b69
 				}
Matthew Barnes ad2b69
 			}
Matthew Barnes ad2b69
@@ -3507,9 +3463,9 @@
Matthew Barnes ad2b69
 	MESSAGE_LIST_LOCK (ml, hide_lock);
Matthew Barnes ad2b69
 	if (ml->hidden) {
Matthew Barnes ad2b69
 		g_hash_table_destroy (ml->hidden);
Matthew Barnes ad2b69
-		e_mempool_destroy (ml->hidden_pool);
Matthew Barnes ad2b69
+		g_string_chunk_free (ml->hidden_string_chunk);
Matthew Barnes ad2b69
 		ml->hidden = NULL;
Matthew Barnes ad2b69
-		ml->hidden_pool = NULL;
Matthew Barnes ad2b69
+		ml->hidden_string_chunk = NULL;
Matthew Barnes ad2b69
 	}
Matthew Barnes ad2b69
 	ml->hide_before = ML_HIDE_NONE_START;
Matthew Barnes ad2b69
 	ml->hide_after = ML_HIDE_NONE_END;
Matthew Barnes ad2b69
@@ -3545,9 +3501,9 @@
Matthew Barnes ad2b69
 	MESSAGE_LIST_LOCK(ml, hide_lock);
Matthew Barnes ad2b69
 	if (ml->hidden) {
Matthew Barnes ad2b69
 		g_hash_table_destroy (ml->hidden);
Matthew Barnes ad2b69
-		e_mempool_destroy (ml->hidden_pool);
Matthew Barnes ad2b69
+		g_string_chunk_free (ml->hidden_string_chunk);
Matthew Barnes ad2b69
 		ml->hidden = NULL;
Matthew Barnes ad2b69
-		ml->hidden_pool = NULL;
Matthew Barnes ad2b69
+		ml->hidden_string_chunk = NULL;
Matthew Barnes ad2b69
 	}
Matthew Barnes ad2b69
 	ml->hide_before = ML_HIDE_NONE_START;
Matthew Barnes ad2b69
 	ml->hide_after = ML_HIDE_NONE_END;
Matthew Barnes ad2b69
@@ -3558,7 +3514,7 @@
Matthew Barnes ad2b69
 		camel_file_util_decode_fixed_int32 (in, &version);
Matthew Barnes ad2b69
 		if (version == HIDE_STATE_VERSION) {
Matthew Barnes ad2b69
 			ml->hidden = g_hash_table_new(g_str_hash, g_str_equal);
Matthew Barnes ad2b69
-			ml->hidden_pool = e_mempool_new(512, 256, E_MEMPOOL_ALIGN_BYTE);
Matthew Barnes ad2b69
+			ml->hidden_string_chunk = g_string_chunk_new(512);
Matthew Barnes ad2b69
 			camel_file_util_decode_fixed_int32 (in, &lower);
Matthew Barnes ad2b69
 			ml->hide_before = lower;
Matthew Barnes ad2b69
 			camel_file_util_decode_fixed_int32 (in, &upper);
Matthew Barnes ad2b69
@@ -3567,7 +3523,7 @@
Matthew Barnes ad2b69
 				char *olduid, *uid;
Matthew Barnes ad2b69
 				
Matthew Barnes ad2b69
 				if (camel_file_util_decode_string (in, &olduid) != -1) {
Matthew Barnes ad2b69
-					uid =  e_mempool_strdup(ml->hidden_pool, olduid);
Matthew Barnes ad2b69
+					uid = g_string_chunk_insert(ml->hidden_string_chunk, olduid);
Matthew Barnes ad2b69
 					g_free (olduid);
Matthew Barnes ad2b69
 					g_hash_table_insert(ml->hidden, uid, uid);
Matthew Barnes ad2b69
 				}
Matthew Barnes ad2b69
@@ -3717,12 +3673,12 @@
Matthew Barnes ad2b69
 			
Matthew Barnes ad2b69
 			if (m->ml->hidden == NULL) {
Matthew Barnes ad2b69
 				m->ml->hidden = g_hash_table_new (g_str_hash, g_str_equal);
Matthew Barnes ad2b69
-				m->ml->hidden_pool = e_mempool_new (512, 256, E_MEMPOOL_ALIGN_BYTE);
Matthew Barnes ad2b69
+				m->ml->hidden_string_chunk = g_string_chunk_new (512);
Matthew Barnes ad2b69
 			}
Matthew Barnes ad2b69
 			
Matthew Barnes ad2b69
 			for (i = 0; i < uidnew->len; i++) {
Matthew Barnes ad2b69
 				if (g_hash_table_lookup (m->ml->hidden, uidnew->pdata[i]) == 0) {
Matthew Barnes ad2b69
-					char *uid = e_mempool_strdup (m->ml->hidden_pool, uidnew->pdata[i]);
Matthew Barnes ad2b69
+					char *uid = g_string_chunk_insert (m->ml->hidden_string_chunk, uidnew->pdata[i]);
Matthew Barnes ad2b69
 					g_hash_table_insert (m->ml->hidden, uid, uid);
Matthew Barnes ad2b69
 				}
Matthew Barnes ad2b69
 			}
Matthew Barnes ad2b69
--- evolution-2.9.1/mail/message-list.h.ememory	2006-09-28 04:56:51.000000000 -0400
Matthew Barnes ad2b69
+++ evolution-2.9.1/mail/message-list.h	2006-10-25 11:15:12.000000000 -0400
Matthew Barnes ad2b69
@@ -102,11 +102,12 @@
Matthew Barnes ad2b69
 	GHashTable *uid_nodemap; /* uid (from info) -> tree node mapping */
Matthew Barnes ad2b69
 	
Matthew Barnes ad2b69
 	GHashTable *normalised_hash;
Matthew Barnes ad2b69
+	GStringChunk *string_chunk;
Matthew Barnes ad2b69
 	
Matthew Barnes ad2b69
 	/* UID's to hide.  Keys in the mempool */
Matthew Barnes ad2b69
 	/* IMPORTANT: You MUST have obtained the hide lock, to operate on this data */
Matthew Barnes ad2b69
 	GHashTable	 *hidden;
Matthew Barnes ad2b69
-	struct _EMemPool *hidden_pool;
Matthew Barnes ad2b69
+	GStringChunk	 *hidden_string_chunk;
Matthew Barnes ad2b69
 	int hide_unhidden;           /* total length, before hiding */
Matthew Barnes ad2b69
 	int hide_before, hide_after; /* hide ranges of messages */
Matthew Barnes ad2b69