toolkit/source/controls/unocontrol.cxx | 41 ++++++++++----------------------- 1 file changed, 13 insertions(+), 28 deletions(-)
New commits: commit 82bf36179ba8369ca026ef3cf400e216255941f1 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Tue Apr 30 21:56:47 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed May 1 19:29:19 2024 +0200 simplify and reduce OUString allocation in UnoControl Change-Id: I276d0b8b1d3fde8aab6be15cb2477ce0c6d175c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166957 Tested-by: Noel Grandin <noel.gran...@collabora.co.uk> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx index 0880455581ea..101e5f75a706 100644 --- a/toolkit/source/controls/unocontrol.cxx +++ b/toolkit/source/controls/unocontrol.cxx @@ -55,25 +55,14 @@ using namespace ::com::sun::star::util; using ::com::sun::star::accessibility::XAccessibleContext; using ::com::sun::star::accessibility::XAccessible; -namespace { - -struct LanguageDependentProp -{ - const char* pPropName; - sal_Int32 nPropNameLength; -}; - -} - -const LanguageDependentProp aLanguageDependentProp[] = -{ - { "Text", 4 }, - { "Label", 5 }, - { "Title", 5 }, - { "HelpText", 8 }, - { "CurrencySymbol", 14 }, - { "StringItemList", 14 }, - { nullptr, 0 } +constexpr OUString aLanguageDependentProp[] = +{ + u"Text"_ustr, + u"Label"_ustr, + u"Title"_ustr, + u"HelpText"_ustr, + u"CurrencySymbol"_ustr, + u"StringItemList"_ustr, }; static Sequence< OUString> lcl_ImplGetPropertyNames( const Reference< XMultiPropertySet > & rxModel ) @@ -579,14 +568,13 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent // Add language dependent properties into the peer property set. // Our resource resolver has been changed and we must be sure // that language dependent props use the new resolver. - const LanguageDependentProp* pLangDepProp = aLanguageDependentProp; - while ( pLangDepProp->pPropName != nullptr ) + + for (const auto & rLangDepProp : aLanguageDependentProp) { bool bMustBeInserted( true ); for (const PropertyValue & i : aPeerPropertiesToSet) { - if ( i.Name.equalsAsciiL( - pLangDepProp->pPropName, pLangDepProp->nPropNameLength )) + if ( i.Name == rLangDepProp ) { bMustBeInserted = false; break; @@ -596,14 +584,11 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent if ( bMustBeInserted ) { // Add language dependent props at the end - OUString aPropName( OUString::createFromAscii( pLangDepProp->pPropName )); - if ( xPSI.is() && xPSI->hasPropertyByName( aPropName ) ) + if ( xPSI.is() && xPSI->hasPropertyByName( rLangDepProp ) ) { - aPeerPropertiesToSet.emplace_back( aPropName, 0, xPS->getPropertyValue( aPropName ), PropertyState_DIRECT_VALUE ); + aPeerPropertiesToSet.emplace_back( rLangDepProp, 0, xPS->getPropertyValue( rLangDepProp ), PropertyState_DIRECT_VALUE ); } } - - ++pLangDepProp; } } aGuard.clear();