summaryrefslogtreecommitdiff
path: root/linguistic/source/lngprophelp.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-09-21 09:56:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-21 14:51:37 +0200
commit96ff90857a066da70b04684f71237056e12eddfe (patch)
tree42558928d3593502fed98970f9632b20bf73300f /linguistic/source/lngprophelp.cxx
parent9994120c8d0fe8c5a029390ad7411b99c18ff5c9 (diff)
reduce cost of some getProperty calls (tdf#125892)
use OUStringLiteral to avoid cost of repeated OUString construction from ascii literal Change-Id: I4f8a4714c093e890adaa5524172bdc91231a561a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122379 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'linguistic/source/lngprophelp.cxx')
-rw-r--r--linguistic/source/lngprophelp.cxx70
1 files changed, 13 insertions, 57 deletions
diff --git a/linguistic/source/lngprophelp.cxx b/linguistic/source/lngprophelp.cxx
index 93bc24e8c04a..bcc3f7a691a4 100644
--- a/linguistic/source/lngprophelp.cxx
+++ b/linguistic/source/lngprophelp.cxx
@@ -48,31 +48,16 @@ namespace linguistic
{
-static const char *aCH[] =
-{
- UPN_IS_IGNORE_CONTROL_CHARACTERS,
- UPN_IS_USE_DICTIONARY_LIST,
-};
-
-const int nCHCount = SAL_N_ELEMENTS(aCH);
-
-
PropertyChgHelper::PropertyChgHelper(
const Reference< XInterface > &rxSource,
Reference< XLinguProperties > const &rxPropSet,
int nAllowedEvents ) :
- aPropNames (nCHCount),
+ aPropNames ({UPN_IS_IGNORE_CONTROL_CHARACTERS, UPN_IS_USE_DICTIONARY_LIST}),
xMyEvtObj (rxSource),
aLngSvcEvtListeners (GetLinguMutex()),
xPropSet (rxPropSet),
nEvtFlags (nAllowedEvents)
{
- OUString *pName = aPropNames.getArray();
- for (sal_Int32 i = 0; i < nCHCount; ++i)
- {
- pName[i] = OUString::createFromAscii( aCH[i] );
- }
-
SetDefaultValues();
}
@@ -80,23 +65,6 @@ PropertyChgHelper::~PropertyChgHelper()
{
}
-
-void PropertyChgHelper::AddPropNames( const char *pNewNames[], sal_Int32 nCount )
-{
- if (pNewNames && nCount)
- {
- sal_Int32 nLen = GetPropNames().getLength();
- GetPropNames().realloc( nLen + nCount );
- OUString *pName = GetPropNames().getArray();
- for (sal_Int32 i = 0; i < nCount; ++i)
- {
- pName[ nLen + i ] = OUString::createFromAscii( pNewNames[ i ] );
-
- }
- }
-}
-
-
void PropertyChgHelper::SetDefaultValues()
{
bResIsIgnoreControlCharacters = bIsIgnoreControlCharacters = true;
@@ -107,7 +75,7 @@ void PropertyChgHelper::SetDefaultValues()
void PropertyChgHelper::GetCurrentValues()
{
const auto& rPropNames = GetPropNames();
- if (!(GetPropSet().is() && rPropNames.hasElements()))
+ if (!GetPropSet().is() || rPropNames.empty())
return;
for (const OUString& rPropName : rPropNames)
@@ -256,7 +224,7 @@ void SAL_CALL PropertyChgHelper::disposing( const EventObject& rSource )
{
RemoveAsPropListener();
xPropSet = nullptr;
- aPropNames.realloc( 0 );
+ aPropNames.clear();
}
}
@@ -316,22 +284,15 @@ void SAL_CALL
}
-// list of properties from the property set to be used
-// and listened to
-static const char *aSP[] =
-{
- UPN_IS_SPELL_UPPER_CASE,
- UPN_IS_SPELL_WITH_DIGITS,
- UPN_IS_SPELL_CAPITALIZATION
-};
-
-
PropertyHelper_Spell::PropertyHelper_Spell(
const Reference< XInterface > & rxSource,
Reference< XLinguProperties > const &rxPropSet ) :
PropertyChgHelper ( rxSource, rxPropSet, AE_SPELLCHECKER )
{
- AddPropNames( aSP, SAL_N_ELEMENTS(aSP) );
+ auto& rPropNames = GetPropNames();
+ rPropNames.push_back(UPN_IS_SPELL_UPPER_CASE);
+ rPropNames.push_back(UPN_IS_SPELL_WITH_DIGITS);
+ rPropNames.push_back(UPN_IS_SPELL_CAPITALIZATION);
SetDefaultValues();
GetCurrentValues();
}
@@ -357,7 +318,7 @@ void PropertyHelper_Spell::GetCurrentValues()
PropertyChgHelper::GetCurrentValues();
const auto& rPropNames = GetPropNames();
- if (!(GetPropSet().is() && rPropNames.hasElements()))
+ if (!GetPropSet().is() || rPropNames.empty())
return;
for (const OUString& rPropName : rPropNames)
@@ -490,20 +451,15 @@ void PropertyHelper_Spell::SetTmpPropVals( const PropertyValues &rPropVals )
}
}
-static const char *aHP[] =
-{
- UPN_HYPH_MIN_LEADING,
- UPN_HYPH_MIN_TRAILING,
- UPN_HYPH_MIN_WORD_LENGTH
-};
-
-
PropertyHelper_Hyphen::PropertyHelper_Hyphen(
const Reference< XInterface > & rxSource,
Reference< XLinguProperties > const &rxPropSet ) :
PropertyChgHelper ( rxSource, rxPropSet, AE_HYPHENATOR )
{
- AddPropNames( aHP, SAL_N_ELEMENTS(aHP) );
+ auto& rPropNames = GetPropNames();
+ rPropNames.push_back(UPN_HYPH_MIN_LEADING);
+ rPropNames.push_back(UPN_HYPH_MIN_TRAILING);
+ rPropNames.push_back(UPN_HYPH_MIN_WORD_LENGTH);
SetDefaultValues();
GetCurrentValues();
}
@@ -530,7 +486,7 @@ void PropertyHelper_Hyphen::GetCurrentValues()
PropertyChgHelper::GetCurrentValues();
const auto& rPropNames = GetPropNames();
- if (!(GetPropSet().is() && rPropNames.hasElements()))
+ if (!GetPropSet().is() || rPropNames.empty())
return;
for (const OUString& rPropName : rPropNames)