[gtk/wip/baedert/for-master: 2/2] inspector: Cache if we have ever constructed a window
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 2/2] inspector: Cache if we have ever constructed a window
- Date: Sat, 7 Aug 2021 10:10:11 +0000 (UTC)
commit f56be65325f5c9b276a9377a35914e118948bed1
Author: Timm Bäder <mail baedert org>
Date: Sat Aug 7 11:58:46 2021 +0200
inspector: Cache if we have ever constructed a window
Silly optimization to get rid of
gtk_main_do_event
gtk_inspector_handle_event
gtk_inspector_window_get_for_display
g_object_get_data
showing up in profiles even though it's useless since we've never even
created any inspector window in the first place.
gtk/inspector/window.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index 02b108d882..6bc0df080a 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -84,6 +84,12 @@ static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW)
+
+/* Fast way of knowing that further checks are necessary because at least
+ * one inspector window has been constructed. */
+static gboolean any_inspector_window_constructed = FALSE;
+
+
static gboolean
set_selected_object (GtkInspectorWindow *iw,
GObject *selected)
@@ -286,6 +292,7 @@ gtk_inspector_window_constructed (GObject *object)
G_OBJECT_CLASS (gtk_inspector_window_parent_class)->constructed (object);
g_object_set_data (G_OBJECT (iw->inspected_display), "-gtk-inspector", iw);
+ any_inspector_window_constructed = TRUE;
gtk_inspector_object_tree_set_display (GTK_INSPECTOR_OBJECT_TREE (iw->object_tree), iw->inspected_display);
gtk_inspector_css_editor_set_display (GTK_INSPECTOR_CSS_EDITOR (iw->css_editor), iw->inspected_display);
@@ -836,6 +843,9 @@ gtk_inspector_is_recording (GtkWidget *widget)
{
GtkInspectorWindow *iw;
+ if (!any_inspector_window_constructed)
+ return FALSE;
+
iw = gtk_inspector_window_get_for_display (gtk_widget_get_display (widget));
if (iw == NULL)
return FALSE;
@@ -853,6 +863,9 @@ gtk_inspector_handle_event (GdkEvent *event)
GtkInspectorWindow *iw;
gboolean handled = FALSE;
+ if (!any_inspector_window_constructed)
+ return FALSE;
+
iw = gtk_inspector_window_get_for_display (gdk_event_get_display (event));
if (iw == NULL)
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]