[gtk+] sizerequest: Optimize CONSTANT_SIZE better



commit 53262cf7a678d07904e81de3f6fa6740f64fb174
Author: Benjamin Otte <otte redhat com>
Date:   Wed Nov 14 14:03:47 2012 +0100

    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 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index 644b47a..7ad9439 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);



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