[clutter] actor: Simplify first/last child updates



commit 62535bdc7350fd65310bf94aea3583577cf5b10e
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 f9e2487..b2f92ae 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -9392,10 +9392,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
     {
@@ -9406,9 +9402,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
@@ -9427,11 +9427,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)
     {
@@ -9442,11 +9437,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
     {
@@ -9469,13 +9459,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
@@ -9504,11 +9497,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
@@ -9537,11 +9530,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]