summaryrefslogtreecommitdiff
path: root/linguistic
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
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')
-rw-r--r--linguistic/source/iprcache.cxx6
-rw-r--r--linguistic/source/lngopt.cxx58
-rw-r--r--linguistic/source/lngprophelp.cxx70
3 files changed, 45 insertions, 89 deletions
diff --git a/linguistic/source/iprcache.cxx b/linguistic/source/iprcache.cxx
index cf9c4db0b266..89db6246f883 100644
--- a/linguistic/source/iprcache.cxx
+++ b/linguistic/source/iprcache.cxx
@@ -41,7 +41,7 @@ namespace linguistic
const struct
{
- const char *pPropName;
+ OUString aPropName;
sal_Int32 nPropHdl;
} aFlushProperties[ NUM_FLUSH_PROPS ] =
{
@@ -62,7 +62,7 @@ static void lcl_AddAsPropertyChangeListener(
for (auto& aFlushPropertie : aFlushProperties)
{
rPropSet->addPropertyChangeListener(
- OUString::createFromAscii(aFlushPropertie.pPropName), xListener );
+ aFlushPropertie.aPropName, xListener );
}
}
}
@@ -77,7 +77,7 @@ static void lcl_RemoveAsPropertyChangeListener(
for (auto& aFlushPropertie : aFlushProperties)
{
rPropSet->removePropertyChangeListener(
- OUString::createFromAscii(aFlushPropertie.pPropName), xListener );
+ aFlushPropertie.aPropName, xListener );
}
}
}
diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx
index 8ddbac6ca9e2..517117306a86 100644
--- a/linguistic/source/lngopt.cxx
+++ b/linguistic/source/lngopt.cxx
@@ -82,7 +82,7 @@ namespace {
struct WID_Name
{
sal_Int32 nWID;
- const char *pPropertyName;
+ OUString aPropertyName;
};
}
@@ -91,7 +91,7 @@ struct WID_Name
//! since the WID is used as index in this table!
WID_Name const aWID_Name[] =
{
- { 0, nullptr },
+ { 0, "" },
{ UPH_IS_USE_DICTIONARY_LIST, UPN_IS_USE_DICTIONARY_LIST },
{ UPH_IS_IGNORE_CONTROL_CHARACTERS, UPN_IS_IGNORE_CONTROL_CHARACTERS },
{ UPH_IS_SPELL_UPPER_CASE, UPN_IS_SPELL_UPPER_CASE },
@@ -102,16 +102,16 @@ WID_Name const aWID_Name[] =
{ UPH_HYPH_MIN_WORD_LENGTH, UPN_HYPH_MIN_WORD_LENGTH },
{ UPH_DEFAULT_LOCALE, UPN_DEFAULT_LOCALE },
{ UPH_IS_SPELL_AUTO, UPN_IS_SPELL_AUTO },
- { 0, nullptr },
- { 0, nullptr },
+ { 0, "" },
+ { 0, "" },
{ UPH_IS_SPELL_SPECIAL, UPN_IS_SPELL_SPECIAL },
{ UPH_IS_HYPH_AUTO, UPN_IS_HYPH_AUTO },
{ UPH_IS_HYPH_SPECIAL, UPN_IS_HYPH_SPECIAL },
{ UPH_IS_WRAP_REVERSE, UPN_IS_WRAP_REVERSE },
- { 0, nullptr },
- { 0, nullptr },
- { 0, nullptr },
- { 0, nullptr },
+ { 0, "" },
+ { 0, "" },
+ { 0, "" },
+ { 0, "" },
{ UPH_DEFAULT_LANGUAGE, UPN_DEFAULT_LANGUAGE },
{ UPH_DEFAULT_LOCALE_CJK, UPN_DEFAULT_LOCALE_CJK },
{ UPH_DEFAULT_LOCALE_CTL, UPN_DEFAULT_LOCALE_CTL }
@@ -125,7 +125,7 @@ OUString LinguOptions::GetName( sal_Int32 nWID )
OUString aRes;
if (0 <= nWID && nWID < sal_Int32(SAL_N_ELEMENTS(aWID_Name)) && aWID_Name[ nWID ].nWID == nWID)
- aRes = OUString::createFromAscii(aWID_Name[nWID].pPropertyName);
+ aRes = aWID_Name[nWID].aPropertyName;
else
OSL_FAIL("lng : unknown WID");
@@ -138,45 +138,45 @@ static const SfxItemPropertyMapEntry* lcl_GetLinguProps()
{
static const SfxItemPropertyMapEntry aLinguProps[] =
{
- { u"" UPN_DEFAULT_LANGUAGE, UPH_DEFAULT_LANGUAGE,
+ { UPN_DEFAULT_LANGUAGE, UPH_DEFAULT_LANGUAGE,
::cppu::UnoType<sal_Int16>::get(), 0, 0 },
- { u"" UPN_DEFAULT_LOCALE, UPH_DEFAULT_LOCALE,
+ { UPN_DEFAULT_LOCALE, UPH_DEFAULT_LOCALE,
::cppu::UnoType<Locale>::get(), 0, 0 },
- { u"" UPN_DEFAULT_LOCALE_CJK, UPH_DEFAULT_LOCALE_CJK,
+ { UPN_DEFAULT_LOCALE_CJK, UPH_DEFAULT_LOCALE_CJK,
::cppu::UnoType<Locale>::get(), 0, 0 },
- { u"" UPN_DEFAULT_LOCALE_CTL, UPH_DEFAULT_LOCALE_CTL,
+ { UPN_DEFAULT_LOCALE_CTL, UPH_DEFAULT_LOCALE_CTL,
::cppu::UnoType<Locale>::get(), 0, 0 },
- { u"" UPN_HYPH_MIN_LEADING, UPH_HYPH_MIN_LEADING,
+ { UPN_HYPH_MIN_LEADING, UPH_HYPH_MIN_LEADING,
::cppu::UnoType<sal_Int16>::get(), 0, 0 },
- { u"" UPN_HYPH_MIN_TRAILING, UPH_HYPH_MIN_TRAILING,
+ { UPN_HYPH_MIN_TRAILING, UPH_HYPH_MIN_TRAILING,
::cppu::UnoType<sal_Int16>::get(), 0, 0 },
- { u"" UPN_HYPH_MIN_WORD_LENGTH, UPH_HYPH_MIN_WORD_LENGTH,
+ { UPN_HYPH_MIN_WORD_LENGTH, UPH_HYPH_MIN_WORD_LENGTH,
::cppu::UnoType<sal_Int16>::get(), 0, 0 },
- { u"" UPN_IS_GERMAN_PRE_REFORM, UPH_IS_GERMAN_PRE_REFORM, /*! deprecated !*/
+ { UPN_IS_GERMAN_PRE_REFORM, UPH_IS_GERMAN_PRE_REFORM, /*! deprecated !*/
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_HYPH_AUTO, UPH_IS_HYPH_AUTO,
+ { UPN_IS_HYPH_AUTO, UPH_IS_HYPH_AUTO,
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_HYPH_SPECIAL, UPH_IS_HYPH_SPECIAL,
+ { UPN_IS_HYPH_SPECIAL, UPH_IS_HYPH_SPECIAL,
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_IGNORE_CONTROL_CHARACTERS, UPH_IS_IGNORE_CONTROL_CHARACTERS,
+ { UPN_IS_IGNORE_CONTROL_CHARACTERS, UPH_IS_IGNORE_CONTROL_CHARACTERS,
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_SPELL_AUTO, UPH_IS_SPELL_AUTO,
+ { UPN_IS_SPELL_AUTO, UPH_IS_SPELL_AUTO,
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_SPELL_CAPITALIZATION, UPH_IS_SPELL_CAPITALIZATION,
+ { UPN_IS_SPELL_CAPITALIZATION, UPH_IS_SPELL_CAPITALIZATION,
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_SPELL_HIDE, UPH_IS_SPELL_HIDE, /*! deprecated !*/
+ { UPN_IS_SPELL_HIDE, UPH_IS_SPELL_HIDE, /*! deprecated !*/
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_SPELL_IN_ALL_LANGUAGES, UPH_IS_SPELL_IN_ALL_LANGUAGES, /*! deprecated !*/
+ { UPN_IS_SPELL_IN_ALL_LANGUAGES, UPH_IS_SPELL_IN_ALL_LANGUAGES, /*! deprecated !*/
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_SPELL_SPECIAL, UPH_IS_SPELL_SPECIAL,
+ { UPN_IS_SPELL_SPECIAL, UPH_IS_SPELL_SPECIAL,
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_SPELL_UPPER_CASE, UPH_IS_SPELL_UPPER_CASE,
+ { UPN_IS_SPELL_UPPER_CASE, UPH_IS_SPELL_UPPER_CASE,
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_SPELL_WITH_DIGITS, UPH_IS_SPELL_WITH_DIGITS,
+ { UPN_IS_SPELL_WITH_DIGITS, UPH_IS_SPELL_WITH_DIGITS,
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_USE_DICTIONARY_LIST, UPH_IS_USE_DICTIONARY_LIST,
+ { UPN_IS_USE_DICTIONARY_LIST, UPH_IS_USE_DICTIONARY_LIST,
cppu::UnoType<bool>::get(), 0, 0 },
- { u"" UPN_IS_WRAP_REVERSE, UPH_IS_WRAP_REVERSE,
+ { UPN_IS_WRAP_REVERSE, UPH_IS_WRAP_REVERSE,
cppu::UnoType<bool>::get(), 0, 0 },
{ u"", 0, css::uno::Type(), 0, 0 }
};
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)