diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-21 11:46:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-21 12:28:23 +0100 |
commit | 48314f25241e014a634dd5371543b90137ffd2bc (patch) | |
tree | c55d6ef485fee3941bc1d3becb106d0dd77e7f2f /basic | |
parent | e41667762bfff43f95d1ee71b2d67903e4fdab4e (diff) |
improve function-local statics in basic..cui
Change-Id: If737e8478f6f1c8fffb060ce132d80e0f07ef8ee
Reviewed-on: https://gerrit.libreoffice.org/63701
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/comp/basiccharclass.cxx | 4 | ||||
-rw-r--r-- | basic/source/runtime/methods.cxx | 15 | ||||
-rw-r--r-- | basic/source/runtime/methods1.cxx | 8 | ||||
-rw-r--r-- | basic/source/runtime/runtime.cxx | 14 |
4 files changed, 10 insertions, 31 deletions
diff --git a/basic/source/comp/basiccharclass.cxx b/basic/source/comp/basiccharclass.cxx index 818190b9fd72..c06bd8bb6047 100644 --- a/basic/source/comp/basiccharclass.cxx +++ b/basic/source/comp/basiccharclass.cxx @@ -34,9 +34,7 @@ bool BasicCharClass::isLetter( sal_Unicode c ) bool BasicCharClass::isLetterUnicode( sal_Unicode c ) { - static CharClass* pCharClass = nullptr; - if( pCharClass == nullptr ) - pCharClass = new CharClass( Application::GetSettings().GetLanguageTag() ); + static CharClass* pCharClass = new CharClass( Application::GetSettings().GetLanguageTag() ); // can we get pCharClass to accept a sal_Unicode instead of this waste? return pCharClass->isLetter( OUString(c), 0 ); } diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 84202c8d4e45..9490ca242f90 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -129,14 +129,7 @@ static long GetDayDiff( const Date& rDate ); static const CharClass& GetCharClass() { - static bool bNeedsInit = true; - static LanguageTag aLanguageTag( LANGUAGE_SYSTEM); - if( bNeedsInit ) - { - bNeedsInit = false; - aLanguageTag = Application::GetSettings().GetLanguageTag(); - } - static CharClass aCharClass( aLanguageTag ); + static CharClass aCharClass( Application::GetSettings().GetLanguageTag() ); return aCharClass; } @@ -169,11 +162,7 @@ OUString getFullPath( const OUString& aRelPath ) // TODO: -> SbiGlobals static uno::Reference< ucb::XSimpleFileAccess3 > const & getFileAccess() { - static uno::Reference< ucb::XSimpleFileAccess3 > xSFI; - if( !xSFI.is() ) - { - xSFI = ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() ); - } + static uno::Reference< ucb::XSimpleFileAccess3 > xSFI = ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() ); return xSFI; } diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index 951c416936bc..32824b6f2c61 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -70,13 +70,7 @@ using namespace com::sun::star::uno; static Reference< XCalendar4 > const & getLocaleCalendar() { - static Reference< XCalendar4 > xCalendar; - if( !xCalendar.is() ) - { - Reference< XComponentContext > xContext = getProcessComponentContext(); - xCalendar = LocaleCalendar2::create(xContext); - } - + static Reference< XCalendar4 > xCalendar = LocaleCalendar2::create(getProcessComponentContext()); static css::lang::Locale aLastLocale; static bool bNeedsInit = true; diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index c8131460accf..f111c65fdb52 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -1337,14 +1337,12 @@ void SbiRuntime::StepCompare( SbxOperator eOp ) // I dumbly follow the pattern :-/ if ( bVBAEnabled && ( p1->IsNull() || p2->IsNull() ) ) { - static SbxVariable* pNULL = nullptr; - - if( !pNULL ) - { - pNULL = new SbxVariable; - pNULL->PutNull(); - pNULL->AddFirstRef(); - } + static SbxVariable* pNULL = [&]() { + SbxVariable* p = new SbxVariable; + p->PutNull(); + p->AddFirstRef(); + return p; + }(); PushVar( pNULL ); } else if( p2->Compare( eOp, *p1 ) ) |