[gtk+] cssbordervalue: Avoid allocating new value if not needed
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssbordervalue: Avoid allocating new value if not needed
- Date: Thu, 21 Apr 2016 21:02:05 +0000 (UTC)
commit f93eca560494ff9ad7657db611296ea961de2ace
Author: Benjamin Otte <otte redhat com>
Date: Thu Apr 21 22:28:40 2016 +0200
cssbordervalue: Avoid allocating new value if not needed
gtk/gtkcssbordervalue.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcssbordervalue.c b/gtk/gtkcssbordervalue.c
index 0b68d86..5140057 100644
--- a/gtk/gtkcssbordervalue.c
+++ b/gtk/gtkcssbordervalue.c
@@ -48,28 +48,33 @@ gtk_css_value_border_compute (GtkCssValue *value,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
+ GtkCssValue *values[4];
GtkCssValue *computed;
gboolean changed = FALSE;
guint i;
- computed = _gtk_css_border_value_new (NULL, NULL, NULL, NULL);
- computed->fill = value->fill;
-
for (i = 0; i < 4; i++)
{
if (value->values[i])
{
- computed->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style,
parent_style);
- changed |= (computed->values[i] != value->values[i]);
+ values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
+ changed |= (values[i] != value->values[i]);
}
}
if (!changed)
{
- _gtk_css_value_unref (computed);
+ for (i = 0; i < 4; i++)
+ {
+ if (values[i] != NULL)
+ _gtk_css_value_unref (values[i]);
+ }
return _gtk_css_value_ref (value);
}
+ computed = _gtk_css_border_value_new (values[0], values[1], values[2], values[3]);
+ computed->fill = value->fill;
+
return computed;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]