mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-12 20:00:09 +00:00
cssshadowsvalue: Avoid allocating new value if not needed
This commit is contained in:
parent
f93eca5604
commit
c081ca2d4c
@ -57,19 +57,40 @@ gtk_css_value_shadows_compute (GtkCssValue *value,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
guint i;
|
||||
GtkCssValue *result, *tmp;
|
||||
guint i, j;
|
||||
|
||||
if (value->len == 0)
|
||||
return _gtk_css_value_ref (value);
|
||||
|
||||
result = gtk_css_shadows_value_new (value->values, value->len);
|
||||
result = NULL;
|
||||
for (i = 0; i < value->len; i++)
|
||||
{
|
||||
result->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
|
||||
tmp = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
|
||||
|
||||
if (result)
|
||||
{
|
||||
result->values[i] = tmp;
|
||||
}
|
||||
else if (tmp != value->values[i])
|
||||
{
|
||||
result = gtk_css_shadows_value_new (value->values, value->len);
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
_gtk_css_value_ref (result->values[j]);
|
||||
}
|
||||
result->values[i] = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
_gtk_css_value_unref (tmp);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
if (result != NULL)
|
||||
return result;
|
||||
else
|
||||
return _gtk_css_value_ref (value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -77,6 +77,21 @@ gtk_css_value_shadow_compute (GtkCssValue *shadow,
|
||||
spread = _gtk_css_value_compute (shadow->spread, property_id, provider, style, parent_style),
|
||||
color = _gtk_css_value_compute (shadow->color, property_id, provider, style, parent_style);
|
||||
|
||||
if (hoffset == shadow->hoffset &&
|
||||
voffset == shadow->voffset &&
|
||||
radius == shadow->radius &&
|
||||
spread == shadow->spread &&
|
||||
color == shadow->color)
|
||||
{
|
||||
_gtk_css_value_unref (hoffset);
|
||||
_gtk_css_value_unref (voffset);
|
||||
_gtk_css_value_unref (radius);
|
||||
_gtk_css_value_unref (spread);
|
||||
_gtk_css_value_unref (color);
|
||||
|
||||
return _gtk_css_value_ref (shadow);
|
||||
}
|
||||
|
||||
return gtk_css_shadow_value_new (hoffset, voffset, radius, spread, shadow->inset, color);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user