[gtk+] styleproperty: Save some memory
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] styleproperty: Save some memory
- Date: Mon, 9 Apr 2012 01:15:48 +0000 (UTC)
commit 8243b16ad79cb4965ab5314e53a20ef16b2af9c3
Author: Benjamin Otte <otte redhat com>
Date: Sat Apr 7 21:32:39 2012 +0200
styleproperty: Save some memory
Only create a new CssValue when we actually need one.
gtk/gtkcssstylepropertyimpl.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 7dd1cf4..0528ae0 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]