[gtk+/wip/css-optimize2: 7/10] css: Short circuit gtk_css_value_initial_compute when possible
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/css-optimize2: 7/10] css: Short circuit gtk_css_value_initial_compute when possible
- Date: Tue, 4 Dec 2012 16:01:51 +0000 (UTC)
commit 340c7f941934d653bf496c9dbd40a007cdb5ad96
Author: Alexander Larsson <alexl redhat com>
Date: Tue Dec 4 14:57:52 2012 +0100
css: Short circuit gtk_css_value_initial_compute when possible
For almost all properties the initial value does not need computing.
If we skip computing these then gtk_css_value_initial_compute goes
from > 6% to 2% in my testcase profiles.
gtk/gtkcssinitialvalue.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssinitialvalue.c b/gtk/gtkcssinitialvalue.c
index f4442f1..e604814 100644
--- a/gtk/gtkcssinitialvalue.c
+++ b/gtk/gtkcssinitialvalue.c
@@ -28,6 +28,7 @@
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
GtkCssStyleProperty *property;
+ gboolean needs_compute;
};
static void
@@ -47,6 +48,9 @@ gtk_css_value_initial_compute (GtkCssValue *value,
{
GtkSettings *settings;
+ if (!value->needs_compute)
+ return _gtk_css_value_ref (_gtk_css_style_property_get_initial_value (value->property));
+
switch (property_id)
{
case GTK_CSS_PROPERTY_FONT_FAMILY:
@@ -140,6 +144,8 @@ _gtk_css_initial_value_get (GtkCssStyleProperty *property)
property->css_initial_value = g_new0 (GtkCssValue, 1);
*property->css_initial_value = initial;
property->css_initial_value->property = property;
+ property->css_initial_value->needs_compute =
+ _gtk_css_value_needs_compute (_gtk_css_style_property_get_initial_value (property));
}
return property->css_initial_value;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]