]> git.saurik.com Git - wxWidgets.git/commitdiff
Avoid useless iteration on all pages in wxBookCtrlBase::DoGetBestSize().
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 27 Sep 2012 12:46:53 +0000 (12:46 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 27 Sep 2012 12:46:53 +0000 (12:46 +0000)
If m_fitToCurrentPage is true, there is no need to iterate over all the pages
computing their max best size only in order to overwrite it with the best size
of the current page later.

This doesn't result in any changes in the behaviour, just avoids useless best
size computations.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72561 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/bookctrl.cpp

index 92846f30aaf5021b1c65de8670a47b7ec146528e..3b1bfc6d1c8fe2d64670b7542ffeeda71d7d1e35 100644 (file)
@@ -137,26 +137,30 @@ wxSize wxBookCtrlBase::DoGetBestSize() const
 {
     wxSize bestSize;
 
-    // iterate over all pages, get the largest width and height
-    const size_t nCount = m_pages.size();
-    for ( size_t nPage = 0; nPage < nCount; nPage++ )
+    if (m_fitToCurrentPage && GetCurrentPage())
+    {
+        bestSize = GetCurrentPage()->GetBestSize();
+    }
+    else
     {
-        const wxWindow * const pPage = m_pages[nPage];
-        if( pPage )
+        // iterate over all pages, get the largest width and height
+        const size_t nCount = m_pages.size();
+        for ( size_t nPage = 0; nPage < nCount; nPage++ )
         {
-            wxSize childBestSize(pPage->GetBestSize());
+            const wxWindow * const pPage = m_pages[nPage];
+            if( pPage )
+            {
+                wxSize childBestSize(pPage->GetBestSize());
 
-            if ( childBestSize.x > bestSize.x )
-                bestSize.x = childBestSize.x;
+                if ( childBestSize.x > bestSize.x )
+                    bestSize.x = childBestSize.x;
 
-            if ( childBestSize.y > bestSize.y )
-                bestSize.y = childBestSize.y;
+                if ( childBestSize.y > bestSize.y )
+                    bestSize.y = childBestSize.y;
+            }
         }
     }
 
-    if (m_fitToCurrentPage && GetCurrentPage())
-        bestSize = GetCurrentPage()->GetBestSize();
-
     // convert display area to window area, adding the size necessary for the
     // tabs
     wxSize best = CalcSizeFromPage(bestSize);