diff options
author | Benjamin Otte <otte@redhat.com> | 2012-04-07 21:32:39 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-04-09 03:14:51 +0200 |
commit | 8243b16ad79cb4965ab5314e53a20ef16b2af9c3 (patch) | |
tree | bd8ec780c076803b946e7ba9654ce380308d6621 | |
parent | fde43d01e524c90eeef1d611a6174b86226b7bd4 (diff) | |
download | gtk+-8243b16ad79cb4965ab5314e53a20ef16b2af9c3.tar.gz |
styleproperty: Save some memory
Only create a new CssValue when we actually need one.
-rw-r--r-- | gtk/gtkcssstylepropertyimpl.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c index 7dd1cf40b8..0528ae05cb 100644 --- a/gtk/gtkcssstylepropertyimpl.c +++ b/gtk/gtkcssstylepropertyimpl.c @@ -400,10 +400,20 @@ css_image_value_compute (GtkCssStyleProperty *property, GtkStyleContext *context, GtkCssValue *specified) { - GtkCssImage *image = _gtk_css_value_get_image (specified); + GtkCssImage *image, *computed; + + image = _gtk_css_value_get_image (specified); - if (image) - image = _gtk_css_image_compute (image, context); + if (image == NULL) + return _gtk_css_value_ref (specified); + + computed = _gtk_css_image_compute (image, context); + + if (computed == image) + { + g_object_unref (computed); + return _gtk_css_value_ref (specified); + } return _gtk_css_value_new_take_image (image); } |