[gtk/wip/baedert/icontheme2: 47/134] cssanimatedstyle: Avoid type check in loop



commit 72c38c46aa19431aa651548e6467b9c02a7c00d5
Author: Timm Bäder <mail baedert org>
Date:   Mon Aug 19 08:46:27 2019 +0200

    cssanimatedstyle: Avoid type check in loop
    
    We can just do the check once as source is not going to change within
    the loop.

 gtk/gtkcssanimatedstyle.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c
index 21cc98c4fc..eb930c4a86 100644
--- a/gtk/gtkcssanimatedstyle.c
+++ b/gtk/gtkcssanimatedstyle.c
@@ -270,6 +270,7 @@ gtk_css_animated_style_create_css_transitions (GSList              *animations,
 {
   TransitionInfo transitions[GTK_CSS_PROPERTY_N_PROPERTIES] = { { 0, } };
   GtkCssValue *durations, *delays, *timing_functions;
+  gboolean source_is_animated;
   guint i;
 
   durations = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_DURATION);
@@ -284,6 +285,7 @@ gtk_css_animated_style_create_css_transitions (GSList              *animations,
 
   transition_infos_set (transitions, gtk_css_style_get_value (base_style, 
GTK_CSS_PROPERTY_TRANSITION_PROPERTY));
 
+  source_is_animated = GTK_IS_CSS_ANIMATED_STYLE (source);
   for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
     {
       GtkStyleAnimation *animation;
@@ -298,14 +300,14 @@ gtk_css_animated_style_create_css_transitions (GSList              *animations,
       if (duration + delay == 0.0)
         continue;
 
-      if (GTK_IS_CSS_ANIMATED_STYLE (source))
+      if (source_is_animated)
         {
-          start = gtk_css_animated_style_get_intrinsic_value (GTK_CSS_ANIMATED_STYLE (source), i);
+          start = gtk_css_animated_style_get_intrinsic_value ((GtkCssAnimatedStyle *)source, i);
           end = gtk_css_style_get_value (base_style, i);
 
           if (_gtk_css_value_equal (start, end))
             {
-              animation = gtk_css_animated_style_find_transition (GTK_CSS_ANIMATED_STYLE (source), i);
+              animation = gtk_css_animated_style_find_transition ((GtkCssAnimatedStyle *)source, i);
               if (animation)
                 {
                   animation = _gtk_style_animation_advance (animation, timestamp);


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