1
0
Fork 0

clutter/actor: Avoid computing GStrv length for simple checks

No need to do a full iteration of the tokens or doing null-checks here
since g_strsplit() is not nullable, while there's no need to do a full
length check either.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4071>
This commit is contained in:
Marco Trevisan (Treviño) 2024-10-07 11:16:20 +02:00 committed by Marge Bot
parent 61c722881d
commit 1985d9ccdd

View file

@ -12021,7 +12021,7 @@ get_layout_from_animation_property (ClutterActor *actor,
return FALSE;
tokens = g_strsplit (name, ".", -1);
if (tokens == NULL || g_strv_length (tokens) != 2)
if (tokens[0] == NULL || tokens[1] == NULL || tokens[2] != NULL)
{
CLUTTER_NOTE (ANIMATION, "Invalid property name '%s'",
name + 1);
@ -12052,7 +12052,7 @@ get_content_from_animation_property (ClutterActor *actor,
}
tokens = g_strsplit (name, ".", -1);
if (tokens == NULL || g_strv_length (tokens) != 2)
if (tokens[0] == NULL || tokens[1] == NULL || tokens[2] != NULL)
{
CLUTTER_NOTE (ANIMATION, "Invalid property name '%s'",
name + 1);
@ -12092,7 +12092,7 @@ get_meta_from_animation_property (ClutterActor *actor,
*/
tokens = g_strsplit (name + 1, ".", -1);
if (tokens == NULL || g_strv_length (tokens) != 3)
if (g_strv_length (tokens) != 3)
{
CLUTTER_NOTE (ANIMATION, "Invalid property name '%s'",
name + 1);