[gtk/matthiasc/for-master: 9/9] css: Fix the initial values optimization
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 9/9] css: Fix the initial values optimization
- Date: Tue, 4 Feb 2020 11:33:25 +0000 (UTC)
commit b8ffe5b2452f829c45271c64743af89d38f78230
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Feb 4 12:19:23 2020 +0100
css: Fix the initial values optimization
Fix up the index computation. We have duplicate entries
in the type enum, so to go from one of the 'initial' types
to it corresponding type you subtract one, but to find
the size array entry for a type, you divide by 2.
gtk/gtkcssstyle.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c
index 5707b0eb55..ecfc3f45cd 100644
--- a/gtk/gtkcssstyle.c
+++ b/gtk/gtkcssstyle.c
@@ -690,30 +690,21 @@ gtk_css_style_get_pango_font (GtkCssStyle *style)
static int values_size[] = {
sizeof (GtkCssCoreValues),
- sizeof (GtkCssCoreValues),
- sizeof (GtkCssBackgroundValues),
sizeof (GtkCssBackgroundValues),
sizeof (GtkCssBorderValues),
- sizeof (GtkCssBorderValues),
sizeof (GtkCssIconValues),
- sizeof (GtkCssIconValues),
- sizeof (GtkCssOutlineValues),
sizeof (GtkCssOutlineValues),
sizeof (GtkCssFontValues),
- sizeof (GtkCssFontValues),
- sizeof (GtkCssFontVariantValues),
sizeof (GtkCssFontVariantValues),
sizeof (GtkCssAnimationValues),
- sizeof (GtkCssAnimationValues),
sizeof (GtkCssTransitionValues),
- sizeof (GtkCssTransitionValues),
- sizeof (GtkCssSizeValues),
sizeof (GtkCssSizeValues),
- sizeof (GtkCssOtherValues),
sizeof (GtkCssOtherValues)
};
-#define N_VALUES(type) ((values_size[type] - sizeof (GtkCssValues)) / sizeof (GtkCssValue *))
+#define TYPE_INDEX(type) ((type) - ((type) % 2))
+#define VALUES_SIZE(type) (values_size[(type) / 2])
+#define N_VALUES(type) ((VALUES_SIZE(type) - sizeof (GtkCssValues)) / sizeof (GtkCssValue *))
#define GET_VALUES(v) (GtkCssValue **)((guint8 *)(v) + sizeof (GtkCssValues))
@@ -757,7 +748,7 @@ gtk_css_values_copy (GtkCssValues *values)
GtkCssValue **v, **v2;
int i;
- copy = gtk_css_values_new (values->type - (values->type % 2));
+ copy = gtk_css_values_new (TYPE_INDEX(values->type));
v = GET_VALUES (values);
v2 = GET_VALUES (copy);
@@ -776,9 +767,9 @@ gtk_css_values_new (GtkCssValuesType type)
{
GtkCssValues *values;
- values = (GtkCssValues *)g_malloc0 (values_size[type]);
+ values = (GtkCssValues *)g_malloc0 (VALUES_SIZE(type));
values->ref_count = 1;
- values->type = type - (type % 2);
+ values->type = type;
return values;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]