[gtk/wip/baedert/css-values: 3/3] css: Use a singleton for builtin image values
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/css-values: 3/3] css: Use a singleton for builtin image values
- Date: Fri, 10 Jan 2020 16:57:54 +0000 (UTC)
commit 9199b54dc4101f8675daf282cc308d41850f12cb
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jan 9 19:50:53 2020 -0500
css: Use a singleton for builtin image values
There's only a singleton builtin image, so there
is not much point in creating 1000s of values holding
the it. Just make it a singleton.
gtk/gtkcssimagevalue.c | 10 ++++++++++
1 file changed, 10 insertions(+)
---
diff --git a/gtk/gtkcssimagevalue.c b/gtk/gtkcssimagevalue.c
index 1a628a568f..8ddc88b7a0 100644
--- a/gtk/gtkcssimagevalue.c
+++ b/gtk/gtkcssimagevalue.c
@@ -20,6 +20,7 @@
#include "gtkcssimagevalueprivate.h"
#include "gtkcssimagecrossfadeprivate.h"
+#include "gtkcssimagebuiltinprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
@@ -137,11 +138,20 @@ GtkCssValue *
_gtk_css_image_value_new (GtkCssImage *image)
{
static GtkCssValue none_singleton = { >K_CSS_VALUE_IMAGE, 1, NULL };
+ static GtkCssValue builtin_singleton = { >K_CSS_VALUE_IMAGE, 1, NULL };
GtkCssValue *value;
if (image == NULL)
return _gtk_css_value_ref (&none_singleton);
+ if (GTK_IS_CSS_IMAGE_BUILTIN (image))
+ {
+ if (builtin_singleton.image == NULL)
+ builtin_singleton.image = image;
+
+ return _gtk_css_value_ref (&builtin_singleton);
+ }
+
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_IMAGE);
value->image = image;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]