[clutter/wip/apocalypses/apocalypse-1: 59/92] actor: Simplify first/last child updates



commit 5a9f97b93b7073dc89cb39e65d9b5c811f36d21f
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Dec 19 07:20:20 2011 +0000

    actor: Simplify first/last child updates

 clutter/clutter-actor.c |   45 +++++++++++++++++++--------------------------
 1 files changed, 19 insertions(+), 26 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index dd36d6e..591fd27 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -9399,10 +9399,6 @@ insert_child_at_depth (ClutterActor *self,
       child->priv->prev_sibling = iter->priv->prev_sibling;
       child->priv->next_sibling = iter;
       iter->priv->prev_sibling = child;
-
-      /* Update the head of the list */
-      if (self->priv->first_child == iter)
-        self->priv->first_child = child;
     }
   else
     {
@@ -9413,9 +9409,13 @@ insert_child_at_depth (ClutterActor *self,
 
       child->priv->prev_sibling = self->priv->last_child;
       child->priv->next_sibling = NULL;
-
-      self->priv->last_child = child;
     }
+
+  if (child->priv->prev_sibling == NULL)
+    self->priv->first_child = child;
+
+  if (child->priv->next_sibling == NULL)
+    self->priv->last_child = child;
 }
 
 static void
@@ -9434,11 +9434,6 @@ insert_child_at_index (ClutterActor *self,
 
       child->priv->prev_sibling = NULL;
       child->priv->next_sibling = tmp;
-
-      self->priv->first_child = child;
-
-      if (self->priv->last_child == NULL)
-        self->priv->last_child = child;
     }
   else if (index < 0)
     {
@@ -9449,11 +9444,6 @@ insert_child_at_index (ClutterActor *self,
 
       child->priv->prev_sibling = tmp;
       child->priv->next_sibling = NULL;
-
-      self->priv->last_child = child;
-
-      if (self->priv->first_child == NULL)
-        self->priv->first_child = child;
     }
   else
     {
@@ -9476,13 +9466,16 @@ insert_child_at_index (ClutterActor *self,
               if (tmp != NULL)
                 tmp->priv->next_sibling = child;
 
-              if (self->priv->last_child == iter)
-                self->priv->last_child = child;
-
               break;
             }
         }
     }
+
+  if (child->priv->prev_sibling == NULL)
+    self->priv->first_child = child;
+
+  if (child->priv->next_sibling == NULL)
+    self->priv->last_child = child;
 }
 
 static void
@@ -9511,11 +9504,11 @@ insert_child_above (ClutterActor *self,
   else
     child->priv->next_sibling = NULL;
 
-  if (self->priv->last_child == NULL || self->priv->last_child == sibling)
-    self->priv->last_child = child;
+  if (child->priv->prev_sibling == NULL)
+    self->priv->first_child = child;
 
-  if (self->priv->first_child == NULL)
-    self->priv->first_child = sibling != NULL ? sibling : child;
+  if (child->priv->next_sibling == NULL)
+    self->priv->last_child = child;
 }
 
 static void
@@ -9544,11 +9537,11 @@ insert_child_below (ClutterActor *self,
   else
     child->priv->prev_sibling = NULL;
 
-  if (self->priv->first_child == NULL || self->priv->first_child == sibling)
+  if (child->priv->prev_sibling == NULL)
     self->priv->first_child = child;
 
-  if (self->priv->last_child == NULL)
-    self->priv->last_child = sibling != NULL ? sibling : child;
+  if (child->priv->next_sibling == NULL)
+    self->priv->last_child = child;
 }
 
 typedef void (* ClutterActorAddChildFunc) (ClutterActor *parent,



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