[balsa/gtk3] Find node once, not twice



commit c9d2d7460bb7dfddd26ccaa42df06ee42e158dc1
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Jun 25 17:13:53 2012 -0400

    Find node once, not twice
    
    	* libbalsa/mailbox.c (libbalsa_mailbox_msgno_filt_out),
    	(lbm_msgno_filt_check): find node once, not twice.

 ChangeLog          |    5 +++++
 libbalsa/mailbox.c |   20 +++++++-------------
 2 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index def80e4..56482e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-25  Peter Bloomfield
+
+	* libbalsa/mailbox.c (libbalsa_mailbox_msgno_filt_out),
+	(lbm_msgno_filt_check): find node once, not twice.
+
 2012-06-19  Peter Bloomfield
 
 	* libbalsa/mailbox.c (lbm_node_has_unseen_child),
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 859cbd7..45911fd 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -1667,11 +1667,11 @@ libbalsa_mailbox_msgno_removed(LibBalsaMailbox * mailbox, guint seqno)
 }
 
 static void
-libbalsa_mailbox_msgno_filt_out(LibBalsaMailbox * mailbox, guint seqno)
+libbalsa_mailbox_msgno_filt_out(LibBalsaMailbox * mailbox, GNode * node)
 {
     GtkTreeIter iter;
     GtkTreePath *path;
-    GNode *child, *parent, *node;
+    GNode *child, *parent;
 
     gdk_threads_enter();
     if (!mailbox->msg_tree) {
@@ -1679,14 +1679,6 @@ libbalsa_mailbox_msgno_filt_out(LibBalsaMailbox * mailbox, guint seqno)
         return;
     }
 
-    node = g_node_find(mailbox->msg_tree, G_PRE_ORDER, G_TRAVERSE_ALL, 
-                       GUINT_TO_POINTER(seqno));
-    if (!node) {
-        g_warning("filt_out: msgno %d not found", seqno);
-        gdk_threads_leave();
-        return;
-    }
-
     iter.user_data = node;
     iter.stamp = mailbox->stamp;
     path = gtk_tree_model_get_path(GTK_TREE_MODEL(mailbox), &iter);
@@ -1747,6 +1739,7 @@ lbm_msgno_filt_check(LibBalsaMailbox * mailbox, guint seqno,
                      gboolean hold_selected)
 {
     gboolean match;
+    GNode *node;
 
     gdk_threads_enter();
 
@@ -1757,8 +1750,9 @@ lbm_msgno_filt_check(LibBalsaMailbox * mailbox, guint seqno,
 
     match = search_iter ?
         libbalsa_mailbox_message_match(mailbox, seqno, search_iter) : TRUE;
-    if (g_node_find(mailbox->msg_tree, G_PRE_ORDER, G_TRAVERSE_ALL,
-                    GUINT_TO_POINTER(seqno))) {
+    node = g_node_find(mailbox->msg_tree, G_PRE_ORDER, G_TRAVERSE_ALL,
+                    GUINT_TO_POINTER(seqno));
+    if (node) {
         if (!match) {
             gboolean filt_out = hold_selected ?
                 libbalsa_mailbox_msgno_has_flags(mailbox, seqno, 0,
@@ -1775,7 +1769,7 @@ lbm_msgno_filt_check(LibBalsaMailbox * mailbox, guint seqno,
 		filt_out = FALSE;
 #endif
             if (filt_out)
-                libbalsa_mailbox_msgno_filt_out(mailbox, seqno);
+                libbalsa_mailbox_msgno_filt_out(mailbox, node);
         }
     } else {
         if (match)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]