balsa r7832 - in branches/mailbox-gsequence: . libbalsa
- From: PeterB svn gnome org
- To: svn-commits-list gnome org
- Subject: balsa r7832 - in branches/mailbox-gsequence: . libbalsa
- Date: Mon, 28 Jan 2008 02:06:27 +0000 (GMT)
Author: PeterB
Date: Mon Jan 28 02:06:26 2008
New Revision: 7832
URL: http://svn.gnome.org/viewvc/balsa?rev=7832&view=rev
Log:
reimplement lbm_node_find
Modified:
branches/mailbox-gsequence/ChangeLog
branches/mailbox-gsequence/configure.in
branches/mailbox-gsequence/libbalsa/mailbox.c
branches/mailbox-gsequence/libbalsa/mailbox.h
Modified: branches/mailbox-gsequence/configure.in
==============================================================================
--- branches/mailbox-gsequence/configure.in (original)
+++ branches/mailbox-gsequence/configure.in Mon Jan 28 02:06:26 2008
@@ -337,6 +337,7 @@
AC_SUBST(BONOBO_ACTIVATION_IDL)
AC_SUBST(BALSA_CFLAGS)
+BALSA_LIBS="$BALSA_LIBS -pg"
AC_SUBST(BALSA_LIBS)
AC_SUBST(BALSA_AB_LIBS)
@@ -765,7 +766,7 @@
if test -d "${srcdir}/.svn" ; then
BALSA_FROM_SVN=yes
- BALSA_CFLAGS="$BALSA_CFLAGS -Wall -Werror"
+ BALSA_CFLAGS="$BALSA_CFLAGS -Wall -Werror -pg"
else
BALSA_FROM_SVN=no
fi
Modified: branches/mailbox-gsequence/libbalsa/mailbox.c
==============================================================================
--- branches/mailbox-gsequence/libbalsa/mailbox.c (original)
+++ branches/mailbox-gsequence/libbalsa/mailbox.c Mon Jan 28 02:06:26 2008
@@ -523,6 +523,8 @@
mailbox->stamp++;
if(mailbox->mindex) g_warning("mindex set - I leak memory");
mailbox->mindex = g_ptr_array_new();
+ if(mailbox->nodes) g_warning("nodes set - I leak memory");
+ mailbox->nodes = g_ptr_array_new();
saved_state = mailbox->state;
mailbox->state = LB_MAILBOX_STATE_OPENING;
@@ -534,6 +536,7 @@
} else {
mailbox->state = saved_state;
libbalsa_mailbox_free_mindex(mailbox);
+ g_ptr_array_free(mailbox->nodes, TRUE);
}
}
@@ -572,6 +575,7 @@
guint msgno;
GSequenceIter *parent;
GSequence *children;
+ GPtrArray *nodes;
} LibBalsaMailboxSequenceInfo;
guint
@@ -613,6 +617,8 @@
{
if (info->children)
g_sequence_free(info->children);
+ if (info->msgno <= info->nodes->len)
+ g_ptr_array_index(info->nodes, info->msgno - 1) = NULL;
g_free(info);
}
@@ -628,26 +634,10 @@
/* Called recursively; must cope with an empty GSequence. */
static GSequenceIter *
-lbm_node_find(GSequence * seq, guint msgno)
+lbm_node_find(LibBalsaMailbox * mailbox, guint msgno)
{
- GSequenceIter *node;
- GSequenceIter *end = g_sequence_get_end_iter(seq);
-
- for (node = g_sequence_get_begin_iter(seq);
- node != end;
- node = g_sequence_iter_next(node)) {
- LibBalsaMailboxSequenceInfo *info = g_sequence_get(node);
- GSequenceIter *child_node;
-
- if (info->msgno == msgno)
- return node;
-
- if (info->children
- && (child_node = lbm_node_find(info->children, msgno)))
- return child_node;
- }
-
- return NULL;
+ return msgno <= mailbox->nodes->len ?
+ g_ptr_array_index(mailbox->nodes, msgno - 1) : NULL;
}
static gboolean
@@ -709,9 +699,8 @@
return n;
}
-gboolean
-libbalsa_mailbox_node_is_ancestor(GSequenceIter * node,
- GSequenceIter * descendant)
+static gboolean
+lbm_node_is_ancestor(GSequenceIter * node, GSequenceIter * descendant)
{
while (descendant) {
if (node == descendant)
@@ -773,6 +762,14 @@
return NULL;
}
+static void
+lbm_node_cache(LibBalsaMailbox * mailbox, guint msgno, GSequenceIter * node)
+{
+ while (msgno > mailbox->nodes->len)
+ g_ptr_array_add(mailbox->nodes, NULL);
+ g_ptr_array_index(mailbox->nodes, msgno - 1) = node;
+}
+
/*
* End of msg_tree functions.
*/
@@ -798,6 +795,7 @@
}
gdk_threads_leave();
libbalsa_mailbox_free_mindex(mailbox);
+ g_ptr_array_free(mailbox->nodes, TRUE);
mailbox->stamp++;
mailbox->state = LB_MAILBOX_STATE_CLOSED;
}
@@ -1347,7 +1345,7 @@
return;
if (iter->user_data == NULL)
- iter->user_data = lbm_node_find(mailbox->msg_tree, seqno);
+ iter->user_data = lbm_node_find(mailbox, seqno);
/* trying to modify seqno that is not in the tree? Possible for
* filtered views... Perhaps there is nothing to worry about.
*/
@@ -1413,6 +1411,7 @@
info->parent = parent;
info->msgno = seqno;
info->children = NULL;
+ info->nodes = mailbox->nodes;
if (sibling) {
insert = g_sequence_iter_next(sibling);
@@ -1422,6 +1421,7 @@
parent ? lbm_node_init_children(parent) : mailbox->msg_tree;
insert = g_sequence_prepend(seq, info);
}
+ lbm_node_cache(mailbox, seqno, insert);
if (g_signal_has_handler_pending(mailbox,
libbalsa_mbox_model_signals
@@ -1458,8 +1458,10 @@
/* Insert node into the message tree before getting path. */
info = g_new0(LibBalsaMailboxSequenceInfo, 1);
info->msgno = seqno;
+ info->nodes = mailbox->nodes;
iter.user_data = g_sequence_prepend(mailbox->msg_tree, info);
iter.stamp = mailbox->stamp;
+ lbm_node_cache(mailbox, seqno, iter.user_data);
/* This item is now the first in the tree: */
path = gtk_tree_path_new_first();
@@ -1620,7 +1622,7 @@
match = search_iter ?
libbalsa_mailbox_message_match(mailbox, seqno, search_iter) : TRUE;
- if ((node = lbm_node_find(mailbox->msg_tree, seqno)) != NULL) {
+ if ((node = lbm_node_find(mailbox, seqno)) != NULL) {
if (!match) {
gboolean filt_out = hold_selected ?
libbalsa_mailbox_msgno_has_flags(mailbox, seqno, 0,
@@ -1693,7 +1695,7 @@
g_return_val_if_fail(seqno > 0, FALSE);
if (!mailbox->msg_tree || !(tmp_iter.user_data =
- lbm_node_find(mailbox->msg_tree, seqno)))
+ lbm_node_find(mailbox, seqno)))
return FALSE;
tmp_iter.stamp = mailbox->stamp;
@@ -3623,7 +3625,7 @@
g_warning("Thread is not holding gdk lock");
if (libbalsa_mailbox_get_parent(node) == parent
- || libbalsa_mailbox_node_is_ancestor(node, parent))
+ || lbm_node_is_ancestor(node, parent))
return;
iter.stamp = mailbox->stamp;
@@ -4198,6 +4200,11 @@
retval = TRUE;
break;
}
+ if (!node)
+ node = forward ?
+ g_sequence_get_begin_iter(mailbox->msg_tree) :
+ g_sequence_iter_prev(g_sequence_get_end_iter
+ (mailbox->msg_tree));
}
if (retval)
Modified: branches/mailbox-gsequence/libbalsa/mailbox.h
==============================================================================
--- branches/mailbox-gsequence/libbalsa/mailbox.h (original)
+++ branches/mailbox-gsequence/libbalsa/mailbox.h Mon Jan 28 02:06:26 2008
@@ -219,6 +219,7 @@
GPtrArray *mindex; /* the basic message index used for index
* displaying/columns of GtkTreeModel interface
* and NOTHING else. */
+ GPtrArray *nodes; /* map msgno to a node in msg_tree */
GSequence *msg_tree; /* the possibly filtered tree of messages;
* gdk lock MUST BE HELD when accessing. */
LibBalsaCondition *view_filter; /* to choose a subset of messages
@@ -530,8 +531,6 @@
guint libbalsa_mailbox_n_nodes(LibBalsaMailbox * mailbox);
guint libbalsa_mailbox_get_msgno(GSequenceIter * node);
GSequenceIter *libbalsa_mailbox_get_parent(GSequenceIter * node);
-gboolean libbalsa_mailbox_node_is_ancestor(GSequenceIter * node,
- GSequenceIter * descendant);
/* Mailbox views. */
extern GHashTable *libbalsa_mailbox_view_table;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]