vcl/source/window/menu.cxx |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

New commits:
commit b0a9be01890578d239bcb958dec33c301986519d
Author:     Rafał Dobrakowski <[email protected]>
AuthorDate: Mon Mar 10 11:14:17 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Tue May 13 15:10:42 2025 +0200

    tdf#153294 Optimize item index retrieval in Menu::GetCharacterBounds()
    
    using std::find.
    
    Change-Id: Ia72d77025ea0308e336d0b0b5497fedada7e73cd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182729
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 8603eb183a11..e3df90c51920 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2265,13 +2265,10 @@ tools::Rectangle Menu::GetCharacterBounds( sal_uInt16 
nItemID, tools::Long nInde
         ImplFillLayoutData();
     if( mpLayoutData )
     {
-        for( size_t i = 0; i < mpLayoutData->m_aLineItemIds.size(); i++ )
+        auto it = std::find(mpLayoutData->m_aLineItemIds.begin(), 
mpLayoutData->m_aLineItemIds.end(), nItemID);
+        if (it != mpLayoutData->m_aLineItemIds.end())
         {
-            if( mpLayoutData->m_aLineItemIds[i] == nItemID )
-            {
-                nItemIndex = mpLayoutData->m_aLineIndices[i];
-                break;
-            }
+            nItemIndex = 
mpLayoutData->m_aLineIndices[std::distance(mpLayoutData->m_aLineItemIds.begin(),
 it)];
         }
     }
     return (mpLayoutData && nItemIndex != -1) ? 
mpLayoutData->GetCharacterBounds( nItemIndex+nIndex ) : tools::Rectangle();

Reply via email to