[gtk+] Avoid type checking overhead for resize-mode
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Avoid type checking overhead for resize-mode
- Date: Sat, 12 Sep 2015 17:06:54 +0000 (UTC)
commit 3eacfa88f2d9c690a006de9cac1cd3c60901686c
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Sep 11 17:12:35 2015 -0400
Avoid type checking overhead for resize-mode
gtk/gtkcontainer.c | 25 +++----------------------
gtk/gtkcontainerprivate.h | 28 ++++++++++++++++++++++++++++
gtk/gtkcsswidgetnode.c | 4 ++--
gtk/gtkwidget.c | 2 --
gtk/gtkwindow.c | 4 ++--
5 files changed, 35 insertions(+), 28 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 16337b5..4bc8e84 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -251,25 +251,6 @@
*
*/
-
-struct _GtkContainerPrivate
-{
- GtkWidget *focus_child;
-
- GdkFrameClock *resize_clock;
- guint resize_handler;
-
- guint border_width : 16;
- guint border_width_set : 1;
-
- guint has_focus_chain : 1;
- guint reallocate_redraws : 1;
- guint resize_pending : 1;
- guint restyle_pending : 1;
- guint resize_mode : 2;
- guint request_mode : 2;
-};
-
enum {
ADD,
REMOVE,
@@ -2071,7 +2052,7 @@ gtk_container_queue_resize_handler (GtkContainer *container)
GtkWidget *widget;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- g_return_if_fail (GTK_IS_RESIZE_CONTAINER (container));
+ g_return_if_fail (_GTK_IS_RESIZE_CONTAINER (container));
G_GNUC_END_IGNORE_DEPRECATIONS;
widget = GTK_WIDGET (container);
@@ -2116,7 +2097,7 @@ _gtk_container_queue_resize_internal (GtkContainer *container,
_gtk_size_request_cache_clear (_gtk_widget_peek_request_cache (widget));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- if (((GtkContainer*)widget)->priv->resize_mode != GTK_RESIZE_PARENT)
+ if (_GTK_IS_RESIZE_CONTAINER (container))
break;
G_GNUC_END_IGNORE_DEPRECATIONS;
@@ -2204,7 +2185,7 @@ gtk_container_real_check_resize (GtkContainer *container)
requisition.height > allocation.height)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- if (GTK_IS_RESIZE_CONTAINER (container))
+ if (_GTK_IS_RESIZE_CONTAINER (container))
{
gtk_widget_size_allocate (widget, &allocation);
gtk_widget_set_allocation (widget, &allocation);
diff --git a/gtk/gtkcontainerprivate.h b/gtk/gtkcontainerprivate.h
index ec81720..fa52481 100644
--- a/gtk/gtkcontainerprivate.h
+++ b/gtk/gtkcontainerprivate.h
@@ -24,6 +24,24 @@
G_BEGIN_DECLS
+struct _GtkContainerPrivate
+{
+ GtkWidget *focus_child;
+
+ GdkFrameClock *resize_clock;
+ guint resize_handler;
+
+ guint border_width : 16;
+ guint border_width_set : 1;
+
+ guint has_focus_chain : 1;
+ guint reallocate_redraws : 1;
+ guint resize_pending : 1;
+ guint restyle_pending : 1;
+ guint resize_mode : 2;
+ guint request_mode : 2;
+};
+
void _gtk_container_queue_resize (GtkContainer *container);
void _gtk_container_queue_restyle (GtkContainer *container);
@@ -44,6 +62,16 @@ gboolean _gtk_container_get_border_width_set (GtkContainer *container);
void _gtk_container_set_border_width_set (GtkContainer *container,
gboolean border_width_set);
+static inline GtkResizeMode _gtk_container_get_resize_mode (GtkContainer *container);
+
+static inline GtkResizeMode
+_gtk_container_get_resize_mode (GtkContainer *container)
+{
+ return container->priv->resize_mode;
+}
+
+#define _GTK_IS_RESIZE_CONTAINER(container) (_gtk_container_get_resize_mode (GTK_CONTAINER (container)) !=
GTK_RESIZE_PARENT)
+
G_END_DECLS
#endif /* __GTK_CONTAINER_PRIVATE_H__ */
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index cf68fb4..e9d2056 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -101,7 +101,7 @@ gtk_css_widget_node_queue_validate (GtkCssNode *node)
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- if (GTK_IS_RESIZE_CONTAINER (widget_node->widget))
+ if (_GTK_IS_RESIZE_CONTAINER (widget_node->widget))
widget_node->validate_cb_id = gtk_widget_add_tick_callback (widget_node->widget,
gtk_css_widget_node_queue_callback,
node,
@@ -115,7 +115,7 @@ gtk_css_widget_node_dequeue_validate (GtkCssNode *node)
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- if (GTK_IS_RESIZE_CONTAINER (widget_node->widget))
+ if (_GTK_IS_RESIZE_CONTAINER (widget_node->widget))
gtk_widget_remove_tick_callback (widget_node->widget,
widget_node->validate_cb_id);
G_GNUC_END_IGNORE_DEPRECATIONS
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 4d714b2..4cb285c 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -17223,8 +17223,6 @@ _gtk_widget_add_controller (GtkWidget *widget,
EventControllerData *data;
GtkWidgetPrivate *priv;
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (GTK_IS_EVENT_CONTROLLER (controller));
g_return_if_fail (widget == gtk_event_controller_get_widget (controller));
priv = widget->priv;
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index b693f94..55ad1ff 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -9444,7 +9444,7 @@ gtk_window_move_resize (GtkWindow *window)
gtk_widget_size_allocate (widget, &allocation);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- if (gtk_container_get_resize_mode (container) == GTK_RESIZE_QUEUE)
+ if (_gtk_container_get_resize_mode (container) == GTK_RESIZE_QUEUE)
gtk_widget_queue_draw (widget);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
@@ -9471,7 +9471,7 @@ gtk_window_move_resize (GtkWindow *window)
* we handle those ourselves upon ->configure_notify_received==TRUE.
*/
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- if (gtk_container_get_resize_mode (container) == GTK_RESIZE_QUEUE)
+ if (_gtk_container_get_resize_mode (container) == GTK_RESIZE_QUEUE)
{
gtk_widget_queue_resize_no_redraw (widget);
_gtk_container_dequeue_resize_handler (container);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]