diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-16 11:03:04 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-17 10:49:21 +0200 |
commit | dac29c278531d5474289eb54aa03987c4958ac83 (patch) | |
tree | 25b32b704b15e1aa89fbd1f6a83d5f25db9169d6 /linguistic/source | |
parent | fbad565fcb5ee8d20a1a83838e66b43aeb23bfa4 (diff) |
speedup toUpperCase when called in parallel
by removing locking from CharClass, which means we need to make it an
immutable class
Since SharedStringPool in sc/ stores a pointer to the CharClass in
use, we have to tweak SvtSysLocale so that the object does not change
location.
Change-Id: I2c62d354fa542ebc04e755ce5b9b9e2ddff76a64
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122185
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'linguistic/source')
-rw-r--r-- | linguistic/source/misc.cxx | 22 | ||||
-rw-r--r-- | linguistic/source/spelldsp.cxx | 6 |
2 files changed, 7 insertions, 21 deletions
diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx index 363b5f445a47..f541b97551e6 100644 --- a/linguistic/source/misc.cxx +++ b/linguistic/source/misc.cxx @@ -566,21 +566,10 @@ uno::Reference< XHyphenatedWord > RebuildHyphensAndControlChars( return xRes; } -static CharClass & lcl_GetCharClass() -{ - static CharClass aCC( LanguageTag( LANGUAGE_ENGLISH_US )); - return aCC; -} - -static std::mutex s_GetCharClassMutex; - bool IsUpper( const OUString &rText, sal_Int32 nPos, sal_Int32 nLen, LanguageType nLanguage ) { - std::scoped_lock aGuard( s_GetCharClassMutex ); - - CharClass &rCC = lcl_GetCharClass(); - rCC.setLanguageTag( LanguageTag( nLanguage )); - sal_Int32 nFlags = rCC.getStringType( rText, nPos, nLen ); + CharClass aCC(( LanguageTag( nLanguage ) )); + sal_Int32 nFlags = aCC.getStringType( rText, nPos, nLen ); return (nFlags & KCharacterType::UPPER) && !(nFlags & KCharacterType::LOWER); } @@ -612,11 +601,8 @@ CapType capitalType(const OUString& aTerm, CharClass const * pCC) OUString ToLower( const OUString &rText, LanguageType nLanguage ) { - std::scoped_lock aGuard( s_GetCharClassMutex ); - - CharClass &rCC = lcl_GetCharClass(); - rCC.setLanguageTag( LanguageTag( nLanguage )); - return rCC.lowercase( rText ); + CharClass aCC(( LanguageTag( nLanguage ) )); + return aCC.lowercase( rText ); } // sorted(!) array of unicode ranges for code points that are exclusively(!) used as numbers diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx index dbece3def648..c1b309b00adf 100644 --- a/linguistic/source/spelldsp.cxx +++ b/linguistic/source/spelldsp.cxx @@ -813,9 +813,9 @@ void SpellCheckerDispatcher::FlushSpellCache() void SpellCheckerDispatcher::setCharClass(const LanguageTag& rLanguageTag) { - if (!m_pCharClass) - m_pCharClass.reset( new CharClass(rLanguageTag) ); - m_pCharClass->setLanguageTag(rLanguageTag); + if (m_pCharClass && m_pCharClass->getLanguageTag() == rLanguageTag) + return; + m_pCharClass.reset( new CharClass(rLanguageTag) ); } |