summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-03-12 14:50:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-14 08:24:10 +0100
commit2eed1c83d0026d0af3e7363da9a90b5e99e69b88 (patch)
tree5143e83b9dd2215cbaff2a7d552651a467e75994 /i18npool
parent5247e5e254632e111bbdb798ee1c714c0c9ebde8 (diff)
tdf#147905 calc PROPER function doesn't like mulithreading
regression from commit dac29c278531d5474289eb54aa03987c4958ac83 Author: Noel Grandin <noel.grandin@collabora.co.uk> Date: Thu Sep 16 11:03:04 2021 +0200 if you hit Transliteration_casemapping hard enough, like in this test case, the state changes become a problem, so remove that by having multiple copies. Change-Id: I1d795af4370d6f79468387997202ba11c6a9d7b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131441 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131508
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/inc/cclass_unicode.hxx6
-rw-r--r--i18npool/inc/transliteration_body.hxx11
-rw-r--r--i18npool/source/characterclassification/cclass_unicode.cxx19
-rw-r--r--i18npool/source/transliteration/transliteration_body.cxx8
4 files changed, 27 insertions, 17 deletions
diff --git a/i18npool/inc/cclass_unicode.hxx b/i18npool/inc/cclass_unicode.hxx
index 4ae4f5fd362e..4f63b8ea889b 100644
--- a/i18npool/inc/cclass_unicode.hxx
+++ b/i18npool/inc/cclass_unicode.hxx
@@ -94,7 +94,11 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
private:
- rtl::Reference<Transliteration_casemapping> trans;
+ // These are performance sensitive, so we don't want to use locking and switch their state, so just
+ // have multiple copies.
+ rtl::Reference<Transliteration_casemapping> transToUpper;
+ rtl::Reference<Transliteration_casemapping> transToLower;
+ rtl::Reference<Transliteration_casemapping> transToTitle;
// --- parser specific (implemented in cclass_unicode_parser.cxx) ---
diff --git a/i18npool/inc/transliteration_body.hxx b/i18npool/inc/transliteration_body.hxx
index a53aa77d15d2..6c3418fd7994 100644
--- a/i18npool/inc/transliteration_body.hxx
+++ b/i18npool/inc/transliteration_body.hxx
@@ -70,7 +70,16 @@ class Transliteration_casemapping final : public Transliteration_body
{
public:
Transliteration_casemapping();
- void setMappingType(const MappingType rMappingType, const css::lang::Locale& rLocale );
+ void setMappingType( const MappingType rMappingType )
+ {
+ if (nMappingType != rMappingType)
+ nMappingType = rMappingType;
+ }
+ void setLocale( const css::lang::Locale& rLocale )
+ {
+ if (aLocale != rLocale)
+ aLocale = rLocale;
+ }
};
class Transliteration_togglecase final : public Transliteration_body
diff --git a/i18npool/source/characterclassification/cclass_unicode.cxx b/i18npool/source/characterclassification/cclass_unicode.cxx
index 2eb3fdf5f27d..13ea1f687b56 100644
--- a/i18npool/source/characterclassification/cclass_unicode.cxx
+++ b/i18npool/source/characterclassification/cclass_unicode.cxx
@@ -39,7 +39,9 @@ namespace i18npool {
// ----------------------------------------------------;
cclass_Unicode::cclass_Unicode( const uno::Reference < XComponentContext >& rxContext ) :
- trans( new Transliteration_casemapping() ),
+ transToUpper( new Transliteration_casemapping() ),
+ transToLower( new Transliteration_casemapping() ),
+ transToTitle( new Transliteration_casemapping() ),
m_xContext( rxContext ),
nStartTypes( 0 ),
nContTypes( 0 ),
@@ -48,6 +50,9 @@ cclass_Unicode::cclass_Unicode( const uno::Reference < XComponentContext >& rxCo
cDecimalSep( '.' ),
cDecimalSepAlt( 0 )
{
+ transToUpper->setMappingType(MappingType::ToUpper);
+ transToLower->setMappingType(MappingType::ToLower);
+ transToTitle->setMappingType(MappingType::ToTitle);
}
cclass_Unicode::~cclass_Unicode() {
@@ -63,8 +68,8 @@ cclass_Unicode::toUpper( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount,
if (nCount + nPos > len)
nCount = len - nPos;
- trans->setMappingType(MappingType::ToUpper, rLocale);
- return trans->transliterateString2String(Text, nPos, nCount);
+ transToUpper->setLocale(rLocale);
+ return transToUpper->transliterateString2String(Text, nPos, nCount);
}
OUString SAL_CALL
@@ -75,8 +80,8 @@ cclass_Unicode::toLower( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount,
if (nCount + nPos > len)
nCount = len - nPos;
- trans->setMappingType(MappingType::ToLower, rLocale);
- return trans->transliterateString2String(Text, nPos, nCount);
+ transToLower->setLocale(rLocale);
+ return transToLower->transliterateString2String(Text, nPos, nCount);
}
OUString SAL_CALL
@@ -89,7 +94,7 @@ cclass_Unicode::toTitle( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount,
if (nCount + nPos > len)
nCount = len - nPos;
- trans->setMappingType(MappingType::ToTitle, rLocale);
+ transToTitle->setLocale(rLocale);
rtl_uString* pStr = rtl_uString_alloc(nCount);
sal_Unicode* out = pStr->buffer;
rtl::Reference< BreakIteratorImpl > xBrk(new BreakIteratorImpl(m_xContext));
@@ -100,7 +105,7 @@ cclass_Unicode::toTitle( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount,
bdy = xBrk->nextWord(Text, bdy.endPos, rLocale,
WordType::ANYWORD_IGNOREWHITESPACES);
*out = (i == bdy.startPos) ?
- trans->transliterateChar2Char(Text[i]) : Text[i];
+ transToTitle->transliterateChar2Char(Text[i]) : Text[i];
}
*out = 0;
return OUString( pStr, SAL_NO_ACQUIRE );
diff --git a/i18npool/source/transliteration/transliteration_body.cxx b/i18npool/source/transliteration/transliteration_body.cxx
index e1fc11a8d70a..9b05f05b585c 100644
--- a/i18npool/source/transliteration/transliteration_body.cxx
+++ b/i18npool/source/transliteration/transliteration_body.cxx
@@ -191,14 +191,6 @@ Transliteration_casemapping::Transliteration_casemapping()
implementationName = "com.sun.star.i18n.Transliteration.Transliteration_casemapping";
}
-void
-Transliteration_casemapping::setMappingType( const MappingType rMappingType, const Locale& rLocale )
-{
- nMappingType = rMappingType;
- if (aLocale != rLocale)
- aLocale = rLocale;
-}
-
Transliteration_u2l::Transliteration_u2l()
{
nMappingType = MappingType::UpperToLower;