From 53262cf7a678d07904e81de3f6fa6740f64fb174 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 14 Nov 2012 14:03:47 +0100 Subject: [PATCH] sizerequest: Optimize CONSTANT_SIZE better We can set for_size to -1 earlier than we did. Doing so makes sure we only cache one value (as we should in the first place). In GTK 3.6, this worked properly, but with Previously, this check was moved further up to avoid interacting with size groups. But after recent refactorings, size groups are handled way earlier anyway. --- gtk/gtksizerequest.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c index 644b47a521..7ad94398bb 100644 --- a/gtk/gtksizerequest.c +++ b/gtk/gtksizerequest.c @@ -105,6 +105,9 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget, gint nat_size = 0; gboolean found_in_cache; + if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE) + for_size = -1; + cache = _gtk_widget_peek_request_cache (widget); found_in_cache = _gtk_size_request_cache_lookup (cache, orientation, @@ -120,7 +123,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget, if (orientation == GTK_ORIENTATION_HORIZONTAL) { - if (for_size < 0 || gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE) + if (for_size < 0) { push_recursion_check (widget, orientation, for_size); GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_size, &nat_size); @@ -153,7 +156,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget, } else { - if (for_size < 0 || gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE) + if (for_size < 0) { push_recursion_check (widget, orientation, for_size); GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, &min_size, &nat_size);