diff options
author | Noel Grandin <noel@peralex.com> | 2021-11-20 20:47:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-11-22 09:51:25 +0100 |
commit | a6ed7588114c643a4d4821201e81b149e3429f2c (patch) | |
tree | 11230d6bfc6808b3cfc8b05547cf90a7295c5a42 /vcl | |
parent | 131c1c7da8c567636ca55751e49d24cb6d6c9b9e (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/font/font.cxx | 63 |
1 files changed, 42 insertions, 21 deletions
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 ); + } } } |