[gtk/misc-speedups: 9/11] widget: Avoid some unnecessary back-and-forth casting




commit ee6491f7172859c0dfea3acd01d28c5afa45044d
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jul 23 10:18:44 2021 -0400

    widget: Avoid some unnecessary back-and-forth casting
    
    Avoid some unnecessary casting and a redundant early exit.

 gtk/gtkwidget.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 6544a4d024..a032876e55 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6781,7 +6781,7 @@ _gtk_widget_scale_changed (GtkWidget *widget)
 int
 gtk_widget_get_scale_factor (GtkWidget *widget)
 {
-  GtkRoot *root;
+  GtkWidget *root;
   GdkDisplay *display;
   GdkMonitor *monitor;
 
@@ -6795,9 +6795,9 @@ gtk_widget_get_scale_factor (GtkWidget *widget)
         return gdk_surface_get_scale_factor (surface);
     }
 
-  root = _gtk_widget_get_root (widget);
-  if (root && GTK_WIDGET (root) != widget)
-    return gtk_widget_get_scale_factor (GTK_WIDGET (root));
+  root = (GtkWidget *)_gtk_widget_get_root (widget);
+  if (root && root != widget)
+    return gtk_widget_get_scale_factor (root);
 
   /* else fall back to something that is more likely to be right than
    * just returning 1:
@@ -10526,11 +10526,6 @@ gtk_widget_set_alloc_needed (GtkWidget *widget)
       if (GTK_IS_NATIVE (widget))
         gtk_native_queue_relayout (GTK_NATIVE (widget));
 
-      if (!priv->parent && GTK_IS_ROOT (widget))
-        {
-          break;
-        }
-
       widget = priv->parent;
       if (widget == NULL)
         break;


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