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 <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
Rafał Dobrakowski
2025-05-13 15:10:42 +02:00
committed by Michael Weghorn
parent f8f7f2ca96
commit b0a9be0189
+3 -6
View File
@@ -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();