include/comphelper/proparrhlp.hxx | 12 +++---- vcl/source/font/font.cxx | 63 +++++++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 27 deletions(-)
New commits: commit 2d073a759f77f80b44180eea32ba7131ad37b0bd Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sun Nov 21 18:44:38 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Nov 22 09:51:40 2021 +0100 osl::Mutex->std::mutex in OPropertyArrayUsageHelper Change-Id: I4fd784f291fd6606b25520e3f08aa8692132e997 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125634 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/comphelper/proparrhlp.hxx b/include/comphelper/proparrhlp.hxx index 8520ac58f87d..5db95972f556 100644 --- a/include/comphelper/proparrhlp.hxx +++ b/include/comphelper/proparrhlp.hxx @@ -22,7 +22,7 @@ #include <comphelper/propagg.hxx> #include <cppuhelper/propshlp.hxx> -#include <osl/mutex.hxx> +#include <mutex> #include <osl/diagnose.h> namespace comphelper @@ -34,9 +34,9 @@ class OPropertyArrayUsageHelper protected: static sal_Int32 s_nRefCount; static ::cppu::IPropertyArrayHelper* s_pProps; - static osl::Mutex& theMutex() + static std::mutex& theMutex() { - static osl::Mutex SINGLETON; + static std::mutex SINGLETON; return SINGLETON; } public: @@ -92,14 +92,14 @@ template<class TYPE> template <class TYPE> OPropertyArrayUsageHelper<TYPE>::OPropertyArrayUsageHelper() { - ::osl::MutexGuard aGuard(theMutex()); + std::unique_lock aGuard(theMutex()); ++s_nRefCount; } template <class TYPE> OPropertyArrayUsageHelper<TYPE>::~OPropertyArrayUsageHelper() { - ::osl::MutexGuard aGuard(theMutex()); + std::unique_lock aGuard(theMutex()); OSL_ENSURE(s_nRefCount > 0, "OPropertyArrayUsageHelper::~OPropertyArrayUsageHelper : suspicious call : have a refcount of 0 !"); if (!--s_nRefCount) { @@ -114,7 +114,7 @@ template <class TYPE> OSL_ENSURE(s_nRefCount, "OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !"); if (!s_pProps) { - ::osl::MutexGuard aGuard(theMutex()); + std::unique_lock aGuard(theMutex()); if (!s_pProps) { s_pProps = createArrayHelper(); commit a6ed7588114c643a4d4821201e81b149e3429f2c Author: Noel Grandin <n...@peralex.com> AuthorDate: Sat Nov 20 20:47:58 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Nov 22 09:51:25 2021 +0100 tdf#133835 speedup calc autofilter (7) vcl::Font avoid allocating a new instance if the setter doesn't change anything, saves 5% Change-Id: I461a2a8e3709b3f3f20e431cb3b976ad47bed0ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125625 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx index 1681159b015a..ef35c744ee0a 100644 --- a/vcl/source/font/font.cxx +++ b/vcl/source/font/font.cxx @@ -66,21 +66,34 @@ Font::Font( vcl::Font&& rFont ) noexcept : mpImplFont( std::move(rFont.mpImplFon Font::Font( const OUString& rFamilyName, const Size& rSize ) { - mpImplFont->SetFamilyName( rFamilyName ); - mpImplFont->SetFontSize( rSize ); + if (const_cast<const ImplType&>(mpImplFont)->maFamilyName != rFamilyName + || const_cast<const ImplType&>(mpImplFont)->maAverageFontSize != rSize) + { + mpImplFont->SetFamilyName( rFamilyName ); + mpImplFont->SetFontSize( rSize ); + } } Font::Font( const OUString& rFamilyName, const OUString& rStyleName, const Size& rSize ) { - mpImplFont->SetFamilyName( rFamilyName ); - mpImplFont->SetStyleName( rStyleName ); - mpImplFont->SetFontSize( rSize ); + if (const_cast<const ImplType&>(mpImplFont)->maFamilyName != rFamilyName + || const_cast<const ImplType&>(mpImplFont)->maStyleName != rStyleName + || const_cast<const ImplType&>(mpImplFont)->maAverageFontSize != rSize) + { + mpImplFont->SetFamilyName( rFamilyName ); + mpImplFont->SetStyleName( rStyleName ); + mpImplFont->SetFontSize( rSize ); + } } Font::Font( FontFamily eFamily, const Size& rSize ) { - mpImplFont->SetFamilyType( eFamily ); - mpImplFont->SetFontSize( rSize ); + if (const_cast<const ImplType&>(mpImplFont)->meFamily != eFamily + || const_cast<const ImplType&>(mpImplFont)->maAverageFontSize != rSize) + { + mpImplFont->SetFamilyType( eFamily ); + mpImplFont->SetFontSize( rSize ); + } } Font::~Font() @@ -97,9 +110,12 @@ void Font::SetColor( const Color& rColor ) void Font::SetFillColor( const Color& rColor ) { - mpImplFont->maFillColor = rColor; - if ( rColor.IsTransparent() ) - mpImplFont->mbTransparent = true; + if (const_cast<const ImplType&>(mpImplFont)->maFillColor != rColor) + { + mpImplFont->maFillColor = rColor; + if ( rColor.IsTransparent() ) + mpImplFont->mbTransparent = true; + } } void Font::SetTransparent( bool bTransparent ) @@ -116,12 +132,14 @@ void Font::SetAlignment( TextAlign eAlign ) void Font::SetFamilyName( const OUString& rFamilyName ) { - mpImplFont->SetFamilyName( rFamilyName ); + if (const_cast<const ImplType&>(mpImplFont)->maFamilyName != rFamilyName) + mpImplFont->SetFamilyName( rFamilyName ); } void Font::SetStyleName( const OUString& rStyleName ) { - mpImplFont->maStyleName = rStyleName; + if (const_cast<const ImplType&>(mpImplFont)->maStyleName != rStyleName) + mpImplFont->maStyleName = rStyleName; } void Font::SetFontSize( const Size& rSize ) @@ -156,16 +174,19 @@ bool Font::IsSymbolFont() const void Font::SetSymbolFlag( bool bSymbol ) { - mpImplFont->SetSymbolFlag( bSymbol ); - - if ( IsSymbolFont() ) + if (const_cast<const ImplType&>(mpImplFont)->mbSymbolFlag != bSymbol) { - mpImplFont->SetCharSet( RTL_TEXTENCODING_SYMBOL ); - } - else - { - if ( std::as_const(*mpImplFont).GetCharSet() == RTL_TEXTENCODING_SYMBOL ) - mpImplFont->SetCharSet( RTL_TEXTENCODING_DONTKNOW ); + mpImplFont->SetSymbolFlag( bSymbol ); + + if ( IsSymbolFont() ) + { + mpImplFont->SetCharSet( RTL_TEXTENCODING_SYMBOL ); + } + else + { + if ( std::as_const(*mpImplFont).GetCharSet() == RTL_TEXTENCODING_SYMBOL ) + mpImplFont->SetCharSet( RTL_TEXTENCODING_DONTKNOW ); + } } }