diff -up evolution-2.21.2/mail/message-list.c.kill-ememory evolution-2.21.2/mail/message-list.c --- evolution-2.21.2/mail/message-list.c.kill-ememory 2007-12-01 10:22:46.000000000 -0500 +++ evolution-2.21.2/mail/message-list.c 2007-12-01 10:23:43.000000000 -0500 @@ -416,70 +416,28 @@ get_message_info (MessageList *message_l return info; } -static const char * -get_normalised_string (MessageList *message_list, CamelMessageInfo *info, int col) +static const gchar * +get_normalised_string (MessageList *message_list, const gchar *string) { - const char *string, *str; - char *normalised; - EPoolv *poolv; - int index; - - switch (col) { - case COL_SUBJECT_NORM: - string = camel_message_info_subject (info); - index = NORMALISED_SUBJECT; - break; - case COL_FROM_NORM: - string = camel_message_info_from (info); - index = NORMALISED_FROM; - break; - case COL_TO_NORM: - string = camel_message_info_to (info); - index = NORMALISED_TO; - break; - default: - string = NULL; - index = NORMALISED_LAST; - g_warning ("Should not be reached\n"); - } - - /* slight optimisation */ - if (string == NULL || string[0] == '\0') + GHashTable *hash_table = message_list->normalised_hash; + GStringChunk *string_chunk = message_list->string_chunk; + gchar *collation_key, *temp; + + if (string == NULL || *string == '\0') return ""; - - poolv = g_hash_table_lookup (message_list->normalised_hash, camel_message_info_uid (info)); - if (poolv == NULL) { - poolv = e_poolv_new (NORMALISED_LAST); - g_hash_table_insert (message_list->normalised_hash, (char *) camel_message_info_uid (info), poolv); - } else { - str = e_poolv_get (poolv, index); - if (*str) - return str; - } - - if (col == COL_SUBJECT_NORM) { - const unsigned char *subject; - - subject = (const unsigned char *) string; - while (!g_ascii_strncasecmp ((char *)subject, "Re:", 3)) { - subject += 3; - - /* jump over any spaces */ - while (*subject && isspace ((int) *subject)) - subject++; - } - - /* jump over any spaces */ - while (*subject && isspace ((int) *subject)) - subject++; - - string = (const char *) subject; - } - - normalised = g_utf8_collate_key (string, -1); - e_poolv_set (poolv, index, normalised, TRUE); - - return e_poolv_get (poolv, index); + + collation_key = g_hash_table_lookup (hash_table, string); + if (collation_key != NULL) + return collation_key; + + temp = g_utf8_collate_key (string, -1); + collation_key = g_string_chunk_insert_const (string_chunk, temp); + g_free (temp); + + temp = g_string_chunk_insert_const (string_chunk, string); + g_hash_table_insert (hash_table, temp, collation_key); + + return collation_key; } static void @@ -1287,12 +1245,23 @@ ml_tree_value_at (ETreeModel *etm, ETree str = camel_message_info_from (msg_info); return (void *)(str ? str : ""); case COL_FROM_NORM: - return (void *) get_normalised_string (message_list, msg_info, col); + str = camel_message_info_from (msg_info); + return (void *) get_normalised_string (message_list, str); case COL_SUBJECT: str = camel_message_info_subject (msg_info); return (void *)(str ? str : ""); case COL_SUBJECT_NORM: - return (void *) get_normalised_string (message_list, msg_info, col); + str = camel_message_info_subject (msg_info); + while (str != NULL && *str != '\0') { + /* skip over spaces and reply prefixes */ + if (g_ascii_strncasecmp (str, "Re:", 3) == 0) + str += 3; + else if (g_ascii_isspace (*str)) + str++; + else + break; + } + return (void *) get_normalised_string (message_list, str); case COL_SENT: { ETreePath child; @@ -1316,7 +1285,8 @@ ml_tree_value_at (ETreeModel *etm, ETree str = camel_message_info_to (msg_info); return (void *)(str ? str : ""); case COL_TO_NORM: - return (void *) get_normalised_string (message_list, msg_info, col); + str = camel_message_info_to (msg_info); + return (void *) get_normalised_string (message_list, str); case COL_SIZE: return GINT_TO_POINTER (camel_message_info_size(msg_info)); case COL_DELETED: @@ -2066,13 +2036,13 @@ message_list_init (MessageList *message_ gtk_scrolled_window_set_vadjustment ((GtkScrolledWindow *) message_list, adjustment); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (message_list), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); - message_list->normalised_hash = g_hash_table_new_full ( - g_str_hash, g_str_equal, - (GDestroyNotify) NULL, - (GDestroyNotify) e_poolv_destroy); + message_list->normalised_hash = + g_hash_table_new (g_str_hash, g_str_equal); + + message_list->string_chunk = g_string_chunk_new (1024); message_list->hidden = NULL; - message_list->hidden_pool = NULL; + message_list->hidden_string_chunk = NULL; message_list->hide_before = ML_HIDE_NONE_START; message_list->hide_after = ML_HIDE_NONE_END; @@ -2166,15 +2136,16 @@ message_list_finalise (GObject *object) struct _MessageListPrivate *p = message_list->priv; g_hash_table_destroy (message_list->normalised_hash); + g_string_chunk_free (message_list->string_chunk); if (message_list->thread_tree) camel_folder_thread_messages_unref(message_list->thread_tree); if (message_list->hidden) { g_hash_table_destroy(message_list->hidden); - e_mempool_destroy(message_list->hidden_pool); + g_string_chunk_free(message_list->hidden_string_chunk); message_list->hidden = NULL; - message_list->hidden_pool = NULL; + message_list->hidden_string_chunk = NULL; } g_free(message_list->search); @@ -3124,6 +3095,9 @@ message_list_set_folder (MessageList *me /* reset the normalised sort performance hack */ g_hash_table_remove_all (message_list->normalised_hash); + + g_string_chunk_free (message_list->string_chunk); + message_list->string_chunk = g_string_chunk_new (1024); mail_regen_cancel(message_list); @@ -3574,14 +3548,14 @@ message_list_hide_uids (MessageList *ml, MESSAGE_LIST_LOCK (ml, hide_lock); if (ml->hidden == NULL) { ml->hidden = g_hash_table_new (g_str_hash, g_str_equal); - ml->hidden_pool = e_mempool_new (512, 256, E_MEMPOOL_ALIGN_BYTE); + ml->hidden_string_chunk = g_string_chunk_new (512); } - uid = e_mempool_strdup (ml->hidden_pool, uids->pdata[i]); + uid = g_string_chunk_insert (ml->hidden_string_chunk, uids->pdata[i]); g_hash_table_insert (ml->hidden, uid, uid); for ( ; i < uids->len; i++) { if (g_hash_table_lookup (ml->uid_nodemap, uids->pdata[i])) { - uid = e_mempool_strdup (ml->hidden_pool, uids->pdata[i]); + uid = g_string_chunk_insert (ml->hidden_string_chunk, uids->pdata[i]); g_hash_table_insert (ml->hidden, uid, uid); } } @@ -3602,9 +3576,9 @@ message_list_hide_clear (MessageList *ml MESSAGE_LIST_LOCK (ml, hide_lock); if (ml->hidden) { g_hash_table_destroy (ml->hidden); - e_mempool_destroy (ml->hidden_pool); + g_string_chunk_free (ml->hidden_string_chunk); ml->hidden = NULL; - ml->hidden_pool = NULL; + ml->hidden_string_chunk = NULL; } ml->hide_before = ML_HIDE_NONE_START; ml->hide_after = ML_HIDE_NONE_END; @@ -3640,9 +3614,9 @@ load_hide_state (MessageList *ml) MESSAGE_LIST_LOCK(ml, hide_lock); if (ml->hidden) { g_hash_table_destroy (ml->hidden); - e_mempool_destroy (ml->hidden_pool); + g_string_chunk_free (ml->hidden_string_chunk); ml->hidden = NULL; - ml->hidden_pool = NULL; + ml->hidden_string_chunk = NULL; } ml->hide_before = ML_HIDE_NONE_START; ml->hide_after = ML_HIDE_NONE_END; @@ -3653,7 +3627,7 @@ load_hide_state (MessageList *ml) camel_file_util_decode_fixed_int32 (in, &version); if (version == HIDE_STATE_VERSION) { ml->hidden = g_hash_table_new(g_str_hash, g_str_equal); - ml->hidden_pool = e_mempool_new(512, 256, E_MEMPOOL_ALIGN_BYTE); + ml->hidden_string_chunk = g_string_chunk_new(512); camel_file_util_decode_fixed_int32 (in, &lower); ml->hide_before = lower; camel_file_util_decode_fixed_int32 (in, &upper); @@ -3662,7 +3636,7 @@ load_hide_state (MessageList *ml) char *olduid, *uid; if (camel_file_util_decode_string (in, &olduid) != -1) { - uid = e_mempool_strdup(ml->hidden_pool, olduid); + uid = g_string_chunk_insert(ml->hidden_string_chunk, olduid); g_free (olduid); g_hash_table_insert(ml->hidden, uid, uid); } @@ -3811,12 +3785,12 @@ regen_list_exec (struct _regen_list_msg if (m->ml->hidden == NULL) { m->ml->hidden = g_hash_table_new (g_str_hash, g_str_equal); - m->ml->hidden_pool = e_mempool_new (512, 256, E_MEMPOOL_ALIGN_BYTE); + m->ml->hidden_string_chunk = g_string_chunk_new (512); } for (i = 0; i < uidnew->len; i++) { if (g_hash_table_lookup (m->ml->hidden, uidnew->pdata[i]) == NULL) { - char *uid = e_mempool_strdup (m->ml->hidden_pool, uidnew->pdata[i]); + char *uid = g_string_chunk_insert (m->ml->hidden_string_chunk, uidnew->pdata[i]); g_hash_table_insert (m->ml->hidden, uid, uid); } } diff -up evolution-2.21.2/mail/message-list.h.kill-ememory evolution-2.21.2/mail/message-list.h --- evolution-2.21.2/mail/message-list.h.kill-ememory 2007-10-23 06:06:27.000000000 -0400 +++ evolution-2.21.2/mail/message-list.h 2007-12-01 10:22:46.000000000 -0500 @@ -102,11 +102,12 @@ struct _MessageList { GHashTable *uid_nodemap; /* uid (from info) -> tree node mapping */ GHashTable *normalised_hash; + GStringChunk *string_chunk; /* UID's to hide. Keys in the mempool */ /* IMPORTANT: You MUST have obtained the hide lock, to operate on this data */ GHashTable *hidden; - struct _EMemPool *hidden_pool; + GStringChunk *hidden_string_chunk; int hide_unhidden; /* total length, before hiding */ int hide_before, hide_after; /* hide ranges of messages */