[gtk+/wip/cssvalue: 142/142] styleproperty: Save some memory
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssvalue: 142/142] styleproperty: Save some memory
- Date: Sat, 7 Apr 2012 19:58:17 +0000 (UTC)
commit 96a12380d28539dee3587f2ac2c2b2e82250951e
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, 12 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 7f6b4a1..15ca50b 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -566,12 +566,20 @@ css_image_value_compute (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- GtkCssImage *image = _gtk_css_image_value_get_image (specified);
+ GtkCssImage *image, *computed;
+
+ image = _gtk_css_image_value_get_image (specified);
+ if (image == NULL)
+ return _gtk_css_value_ref (specified);
- if (image)
- image = _gtk_css_image_compute (image, context);
+ computed = _gtk_css_image_compute (image, context);
+ if (computed == image)
+ {
+ g_object_unref (computed);
+ return _gtk_css_value_ref (specified);
+ }
- return _gtk_css_image_value_new (image);
+ return _gtk_css_image_value_new (computed);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]