summaryrefslogtreecommitdiff
path: root/gtk/gtkcssdimensionvalue.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2019-11-07 07:32:03 +0100
committerTimm Bäder <mail@baedert.org>2019-11-14 09:15:58 +0100
commitedf56b438ebade5f33a3c4b28e2aab9f0631effc (patch)
treec5aafb922cfd66415a370c990fbd646652be5a2e /gtk/gtkcssdimensionvalue.c
parentcd3cd64769a320538dca9d7fa9737823e9bb2a3a (diff)
downloadgtk+-edf56b438ebade5f33a3c4b28e2aab9f0631effc.tar.gz
css: short-circuit gtk_css_dimension_value_try_add
No need to allocate a new css value for something that we already have, because one of the two values is 0
Diffstat (limited to 'gtk/gtkcssdimensionvalue.c')
-rw-r--r--gtk/gtkcssdimensionvalue.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gtk/gtkcssdimensionvalue.c b/gtk/gtkcssdimensionvalue.c
index d545b65e20..1e9e758e63 100644
--- a/gtk/gtkcssdimensionvalue.c
+++ b/gtk/gtkcssdimensionvalue.c
@@ -235,12 +235,18 @@ gtk_css_value_dimension_multiply (const GtkCssValue *value,
}
static GtkCssValue *
-gtk_css_value_dimension_try_add (const GtkCssValue *value1,
- const GtkCssValue *value2)
+gtk_css_value_dimension_try_add (GtkCssValue *value1,
+ GtkCssValue *value2)
{
if (value1->unit != value2->unit)
return NULL;
+ if (value1->value == 0)
+ return _gtk_css_value_ref (value2);
+
+ if (value2->value == 0)
+ return _gtk_css_value_ref (value1);
+
return gtk_css_dimension_value_new (value1->value + value2->value, value1->unit);
}