From 830561405ceee9b13d548f563948cf8063ea1120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 21 Nov 2020 11:45:57 +0100 Subject: [PATCH] clutter/actor: Clean up real_get_paint_volume() a bit We can get rid of an indentation level and the "ret" variable here and instead simply early-return when we need to. Part-of: --- clutter/clutter/clutter-actor.c | 73 ++++++++++++++------------------- 1 file changed, 30 insertions(+), 43 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index e1a6826db..5ef1c9989 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -5664,7 +5664,7 @@ clutter_actor_real_get_paint_volume (ClutterActor *self, ClutterPaintVolume *volume) { ClutterActorPrivate *priv = self->priv; - gboolean res = TRUE; + ClutterActor *child; /* this should be checked before we call this function, but it's a * good idea to be explicit when it costs us nothing @@ -5698,54 +5698,41 @@ clutter_actor_real_get_paint_volume (ClutterActor *self, * outside the clip region. */ if (priv->clip_to_allocation) + return TRUE; + + /* if we don't have children we just bail out here... */ + if (priv->n_children == 0) + return TRUE; + + /* ...but if we have children then we ask for their paint volume in + * our coordinates. if any of our children replies that it doesn't + * have a paint volume, we bail out + */ + for (child = priv->first_child; + child != NULL; + child = child->priv->next_sibling) { - /* the allocation has already been set, so we just flip the - * return value + const ClutterPaintVolume *child_volume; + + /* we ignore unmapped children, since they won't be painted. + * + * XXX: we also have to ignore mapped children without a valid + * allocation, because apparently some code above Clutter allows + * them. */ - res = TRUE; - } - else - { - ClutterActor *child; + if ((!CLUTTER_ACTOR_IS_MAPPED (child) && + !clutter_actor_has_mapped_clones (child)) || + !clutter_actor_has_allocation (child)) + continue; - /* if we don't have children we just bail out here... */ - if (priv->n_children == 0) - return res; + child_volume = clutter_actor_get_transformed_paint_volume (child, self); + if (child_volume == NULL) + return FALSE; - /* ...but if we have children then we ask for their paint volume in - * our coordinates. if any of our children replies that it doesn't - * have a paint volume, we bail out - */ - for (child = priv->first_child; - child != NULL; - child = child->priv->next_sibling) - { - const ClutterPaintVolume *child_volume; - - /* we ignore unmapped children, since they won't be painted. - * - * XXX: we also have to ignore mapped children without a valid - * allocation, because apparently some code above Clutter allows - * them. - */ - if ((!CLUTTER_ACTOR_IS_MAPPED (child) && - !clutter_actor_has_mapped_clones (child)) || - !clutter_actor_has_allocation (child)) - continue; - - child_volume = clutter_actor_get_transformed_paint_volume (child, self); - if (child_volume == NULL) - { - res = FALSE; - break; - } - - clutter_paint_volume_union (volume, child_volume); - res = TRUE; - } + clutter_paint_volume_union (volume, child_volume); } - return res; + return TRUE; } static gboolean