[gtk+/wip/alexl/optimize-snapshot: 1/7] Skip dynamic type check in css value getters



commit 882290b479c02f2bc6d1d3d85b09dc3cc66dc9b9
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Jan 11 08:51:04 2017 +0100

    Skip dynamic type check in css value getters
    
    This gets called a lot during snapshotting, and this change
    alone brings down snapshot time by almost 10% in a syntethic
    snapshot test.

 gtk/gtkcssanimatedstyle.c |    5 ++---
 gtk/gtkcssstaticstyle.c   |    3 ++-
 gtk/gtkcssstyle.c         |    2 --
 3 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c
index 1e89088..aadaf97 100644
--- a/gtk/gtkcssanimatedstyle.c
+++ b/gtk/gtkcssanimatedstyle.c
@@ -44,7 +44,8 @@ static GtkCssValue *
 gtk_css_animated_style_get_value (GtkCssStyle *style,
                                   guint        id)
 {
-  GtkCssAnimatedStyle *animated = GTK_CSS_ANIMATED_STYLE (style);
+  /* This is called a lot, so we avoid a dynamic type check here */
+  GtkCssAnimatedStyle *animated = (GtkCssAnimatedStyle *) style;
 
   if (animated->animated_values &&
       id < animated->animated_values->len &&
@@ -147,8 +148,6 @@ GtkCssValue *
 gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
                                             guint                id)
 {
-  gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
-
   return gtk_css_style_get_value (style->style, id);
 }
 
diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c
index 217bb06..f8ce970 100644
--- a/gtk/gtkcssstaticstyle.c
+++ b/gtk/gtkcssstaticstyle.c
@@ -44,7 +44,8 @@ static GtkCssValue *
 gtk_css_static_style_get_value (GtkCssStyle *style,
                                 guint        id)
 {
-  GtkCssStaticStyle *sstyle = GTK_CSS_STATIC_STYLE (style);
+  /* This is called a lot, so we avoid a dynamic type check here */
+  GtkCssStaticStyle *sstyle = (GtkCssStaticStyle *) style;
 
   return sstyle->values[id];
 }
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c
index 1d607d8..250371f 100644
--- a/gtk/gtkcssstyle.c
+++ b/gtk/gtkcssstyle.c
@@ -69,8 +69,6 @@ GtkCssValue *
 gtk_css_style_get_value (GtkCssStyle *style,
                           guint        id)
 {
-  gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
-
   return GTK_CSS_STYLE_GET_CLASS (style)->get_value (style, id);
 }
 


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