[gtk/wip/baedert/for-master: 2/2] image: Avoid unnecessary work when constructing



commit afb0d4f104381780174edccd69eb3b0113316ea8
Author: Timm Bäder <mail baedert org>
Date:   Thu Aug 22 10:03:49 2019 +0200

    image: Avoid unnecessary work when constructing
    
    We call gtk_image_clear() during construction, so avoid doing all that
    work if the image is already empty anyway.

 gtk/gtkimage.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index 751ae9de23..599d754fdb 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -1204,10 +1204,12 @@ void
 gtk_image_clear (GtkImage *image)
 {
   GtkImagePrivate *priv = gtk_image_get_instance_private (image);
-  GtkImageType storage_type;
+  GtkImageType storage_type = gtk_image_get_storage_type (image);
+
+  if (storage_type == GTK_IMAGE_EMPTY)
+    return;
 
   g_object_freeze_notify (G_OBJECT (image));
-  storage_type = gtk_image_get_storage_type (image);
 
   if (storage_type != GTK_IMAGE_EMPTY)
     g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_STORAGE_TYPE]);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]