evolution/evolution-2.9.1-kill-ememory.patch
2007-09-04 05:05:26 +00:00

300 lines
10 KiB
Diff

--- evolution-2.9.1/mail/message-list.c.ememory 2006-10-25 11:11:34.000000000 -0400
+++ evolution-2.9.1/mail/message-list.c 2006-10-25 11:15:12.000000000 -0400
@@ -412,70 +412,28 @@
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
@@ -1283,12 +1241,23 @@
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;
@@ -1312,7 +1281,8 @@
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:
@@ -2023,9 +1993,10 @@
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (message_list), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
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;
@@ -2054,14 +2025,6 @@
g_signal_connect (((GtkScrolledWindow *) message_list)->vscrollbar, "value-changed", G_CALLBACK (ml_scrolled), message_list);
}
-static gboolean
-normalised_free (gpointer key, gpointer value, gpointer user_data)
-{
- e_poolv_destroy (value);
-
- return TRUE;
-}
-
static void
message_list_destroy(GtkObject *object)
{
@@ -2127,17 +2090,17 @@
MessageList *message_list = MESSAGE_LIST (object);
struct _MessageListPrivate *p = message_list->priv;
- g_hash_table_foreach (message_list->normalised_hash, (GHFunc) normalised_free, NULL);
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);
@@ -2940,17 +2903,6 @@
d(printf("changed = %d added = %d removed = %d\n",
changes->uid_changed->len, changes->uid_added->len, changes->uid_removed->len));
- for (i = 0; i < changes->uid_removed->len; i++) {
- /* uncache the normalised strings for these uids */
- EPoolv *poolv;
-
- poolv = g_hash_table_lookup (ml->normalised_hash, changes->uid_removed->pdata[i]);
- if (poolv != NULL) {
- g_hash_table_remove (ml->normalised_hash, changes->uid_removed->pdata[i]);
- e_poolv_destroy (poolv);
- }
- }
-
/* check if the hidden state has changed, if so modify accordingly, then regenerate */
if (ml->hidejunk || ml->hidedeleted)
mail_folder_hide_by_flag (folder, ml, &changes, (ml->hidejunk ? CAMEL_MESSAGE_JUNK : 0) | (ml->hidedeleted ? CAMEL_MESSAGE_DELETED : 0));
@@ -3028,7 +2980,11 @@
}
/* reset the normalised sort performance hack */
- g_hash_table_foreach_remove (message_list->normalised_hash, normalised_free, NULL);
+ /* XXX GLib 2.12 added g_hash_table_remove_all() */
+ g_hash_table_destroy (message_list->normalised_hash);
+ message_list->normalised_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ g_string_chunk_free (message_list->string_chunk);
+ message_list->string_chunk = g_string_chunk_new (1024);
mail_regen_cancel(message_list);
@@ -3479,14 +3435,14 @@
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);
}
}
@@ -3507,9 +3463,9 @@
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;
@@ -3545,9 +3501,9 @@
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;
@@ -3558,7 +3514,7 @@
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);
@@ -3567,7 +3523,7 @@
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);
}
@@ -3717,12 +3673,12 @@
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]) == 0) {
- 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);
}
}
--- evolution-2.9.1/mail/message-list.h.ememory 2006-09-28 04:56:51.000000000 -0400
+++ evolution-2.9.1/mail/message-list.h 2006-10-25 11:15:12.000000000 -0400
@@ -102,11 +102,12 @@
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 */