Skip to content
Browse files

styleproperty: Save some memory

Only create a new CssValue when we actually need one.
  • Loading branch information...
1 parent fde43d0 commit 8243b16ad79cb4965ab5314e53a20ef16b2af9c3 Benjamin Otte committed Apr 7, 2012
Showing with 13 additions and 3 deletions.
  1. +13 −3 gtk/gtkcssstylepropertyimpl.c
View
16 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);
}

0 comments on commit 8243b16

Please sign in to comment.
Something went wrong with that request. Please try again.