forked from AuroraMiddleware/gtk
cssbordervalue: Avoid allocating new value if not needed
This commit is contained in:
parent
2fc0d6a91a
commit
f93eca5604
@ -48,28 +48,33 @@ gtk_css_value_border_compute (GtkCssValue *value,
|
|||||||
GtkCssStyle *style,
|
GtkCssStyle *style,
|
||||||
GtkCssStyle *parent_style)
|
GtkCssStyle *parent_style)
|
||||||
{
|
{
|
||||||
|
GtkCssValue *values[4];
|
||||||
GtkCssValue *computed;
|
GtkCssValue *computed;
|
||||||
gboolean changed = FALSE;
|
gboolean changed = FALSE;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
computed = _gtk_css_border_value_new (NULL, NULL, NULL, NULL);
|
|
||||||
computed->fill = value->fill;
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
if (value->values[i])
|
if (value->values[i])
|
||||||
{
|
{
|
||||||
computed->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
|
values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
|
||||||
changed |= (computed->values[i] != value->values[i]);
|
changed |= (values[i] != value->values[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!changed)
|
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);
|
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;
|
return computed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user