From a0d8d4f5da171d603347210dd9c5571f41c876a1 Mon Sep 17 00:00:00 2001 From: djcb Date: Fri, 28 Dec 2012 12:50:29 +0200 Subject: [PATCH] * use Abdo's threading improvements --- lib/mu-threader.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/mu-threader.c b/lib/mu-threader.c index 7e832bdd..662eefc9 100644 --- a/lib/mu-threader.c +++ b/lib/mu-threader.c @@ -249,6 +249,11 @@ handle_references (GHashTable *id_table, MuContainer *c) child = find_or_create_referred (id_table, (gchar*)cur->data, &created); + /* if we find the current message in their own refs, break now + so that parent != c in next step */ + if (child == c) + break; + /*Link the References field's MuContainers together in * the order implied by the References header. @@ -285,11 +290,25 @@ handle_references (GHashTable *id_table, MuContainer *c) Note that at all times, the various ``parent'' and ``child'' fields must be kept inter-consistent. */ - /* optimization: if the the message was newly added, it's by - * definition not reachable yet */ + /* optimization: if the the message was newly added, it's by + definition not reachable yet */ + + /* So, we move c and its descendants to become a child of parent if: + * both are not NULL + * parent is not a descendant of c. + * both are different from each other (guaranteed in last loop) */ + + if (parent && c && !(c->child && mu_container_reachable (c->child, parent))) { + + /* if c already has a parent, remove c from its parent children + and reparent it, as now we know who is c's parent reliably */ + if (c->parent) { + mu_container_remove_child(c->parent, c); + c->next = c->last = c->parent = NULL; + } - if (child_elligible (parent, c, created)) parent = mu_container_append_children (parent, c); + } }