Threading cleanups
- From: Emmanuel <e allaud wanadoo fr>
- To: ML de Balsa <balsa-list gnome org>
- Cc: Pawel Salek <pawsa theochem kth se>
- Subject: Threading cleanups
- Date: Sun, 12 May 2002 19:51:52 +0200
Hi all,
here is a patch that begins to clean-up a bit the threading code. Until
now it compiles and seems to work fine (I have not really modified the
code just simplify/clean code paths). I'll try to put part of message
threading in a thread to see if it improves the UI response a bit.
Bye
Manu
--- balsa-current/src/balsa-index-threading.c Sat May 11 11:02:22 2002
+++ balsa/src/balsa-index-threading.c Sun May 12 15:23:22 2002
@@ -296,14 +296,11 @@
p->next=foo;
foo->prev=p;
}
- if(foo->next) {
- p=foo->next; /* foo has siblings. */
- while(p) {
- p->parent=parent;
- p=p->next;
- }
+ p=foo; /* foo has siblings. */
+ while(p) {
+ p->parent=parent;
+ p=p->next;
}
- foo->parent=parent;
parent=foo;
reference=g_list_next(reference);
continue;
@@ -359,16 +356,22 @@
else{
container->prev->next=container->next;
if(container->next!=NULL) container->next->prev=container->prev;
- if(container->prev!=NULL) container->prev->next=container->next;
+ container->prev->next=container->next;
}
- if(container->next!=NULL) container->next=NULL;
- if(container->prev!=NULL) container->prev=NULL;
}
- if(parent->children!=NULL) {
+ /* If parent had children already, told the first one that now it is
+ the second one by linking it to container that is now the first one */
+ if(parent->children!=NULL)
parent->children->prev=container;
- container->next=parent->children;
- }
+
+ /* Now container is the first child so container->prev must be NULL
+ and we link it to the existing children of parent by setting
+ container->next to parent->children */
+ container->prev=NULL;
+ container->next=parent->children;
+
+ /* Actually set container as the first child, and parent as its parent */
parent->children=container;
container->parent=parent;
}
@@ -470,19 +473,18 @@
}
}
else {
- GSList* foo=root_set;
- while(foo) {
- if(foo->data==node) {
- foo->data=NULL;
+ while(root_set) {
+ if(root_set->data==node) {
+ root_set->data=NULL;
break;
}
- foo=g_slist_next(foo);
+ root_set=g_slist_next(root_set);
}
}
return FALSE;
}
- if(node->children!=NULL && node->data==NULL &&
+ if(node->children!=NULL && node->data==NULL &&
(node->parent!=NULL || node->children->next==NULL)) {
if(node->parent==NULL) {
while(root_set) {
@@ -492,7 +494,7 @@
node->children->parent=NULL;
}
else {
- GNode* foo=node->parent->children;
+ GNode* foo=node->children;
if(node->prev==NULL) {
node->parent->children=node->children;
}
@@ -501,15 +503,14 @@
node->children->prev=node->prev;
}
- foo=node->children;
while(foo->next!=NULL) {
foo->parent=node->parent;
foo=foo->next;
}
- if(foo==node->children) {
- foo->parent=node->parent;
- }
+ /* Reparent the last one also */
+ foo->parent=node->parent;
+
foo->next=node->next;
if(node->next!=NULL)
node->next->prev=foo;
@@ -521,9 +522,7 @@
}
}
}
- return FALSE;
}
-
return FALSE;
}
@@ -757,24 +756,19 @@
return;
}
- if(node->data==NULL && node2->data==NULL) {
+ if(node2->data==NULL) {
reparent(node2, node->children);
node->children=NULL;
return;
}
- if(node->data==NULL && node2->data!=NULL) {
+ if(node->data==NULL) {
reparent(node, node2->children);
node2->children=NULL;
return;
}
- if(node2->data==NULL && node->data!=NULL) {
- reparent(node2, node->children);
- node->children=NULL;
- return;
- }
- if(node2->data!=NULL) {
+ {
LibBalsaMessage *message2=(LibBalsaMessage *)(node2->data);
const gchar* subject2 = LIBBALSA_MESSAGE_GET_SUBJECT(message2);
const gchar* chopped_subject2= chop_re(subject2);
@@ -782,7 +776,7 @@
if((subject2==chopped_subject2) && subject!=chopped_subject) {
GSList* foo=root_set;
reparent(node2, node);
-
+
while(foo) {
if(foo->data==node)
foo->data=NULL;
@@ -884,6 +878,7 @@
GList *p=NULL;
GtkCTree* ctree=GTK_CTREE(bindex->ctree);
GHashTable *msg_table;
+ gint length=0;
msg_table=g_hash_table_new(g_str_hash, g_str_equal);
@@ -895,23 +890,20 @@
while(sibling!=NULL) {
root_children=g_list_append(root_children, sibling);
sibling=GTK_CTREE_ROW(sibling)->sibling;
+ length++;
}
p=root_children;
balsa_window_setup_progress(BALSA_WINDOW(bindex->window),
- g_list_length(p));
+ length);
while(p) {
parent=NULL;
message=MESSAGE(p->data);
if(message->references_for_threading!=NULL) {
- parent= g_hash_table_lookup(
- msg_table,
- g_list_last(message->references_for_threading)->data);
- if(parent!=NULL) {
- if(p->data==NULL)
- printf("null!! 4\n");
- else
- gtk_ctree_move(ctree, p->data, parent, NULL);
- }
+ parent = g_hash_table_lookup(
+ msg_table,
+ g_list_last(message->references_for_threading)->data);
+ if(parent!=NULL)
+ gtk_ctree_move(ctree, p->data, parent, NULL);
}
p=g_list_next(p);
balsa_window_increment_progress(BALSA_WINDOW(bindex->window));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]