Simplify the loop for clutter_actor_contains

This reorganizes the loop for clutter_actor_contains so that it is a
for loop rather than a while loop. Although this is mostly just
nitpicking, I think this change could make the loop slightly faster if
not optimized because it doesn't perform the self == descendant check
twice and it is clearer.
This commit is contained in:
Neil Roberts 2010-09-27 17:51:01 +01:00
parent 99adb88e9b
commit 3068520752

View File

@ -7387,12 +7387,16 @@ gboolean
clutter_actor_contains (ClutterActor *self,
ClutterActor *descendant)
{
ClutterActor *actor;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
g_return_val_if_fail (CLUTTER_IS_ACTOR (descendant), FALSE);
while (descendant != NULL && descendant != self)
descendant = descendant->priv->parent_actor;
return descendant == self;
for (actor = descendant; actor; actor = actor->priv->parent_actor)
if (actor == self)
return TRUE;
return FALSE;
}
/**