[Libreoffice] [PATCH] some changes for better performance, writer.

David Tardon dtardon at redhat.com
Sun Jan 9 21:32:40 PST 2011


On Tue, Jan 10, 2006 at 08:09:17PM -0300, Kayo Hamid wrote:
> diff --git a/sw/source/core/access/acccell.cxx b/sw/source/core/access/acccell.cxx
> index dbd1b51..2479c5c 100644
> --- a/sw/source/core/access/acccell.cxx
> +++ b/sw/source/core/access/acccell.cxx
> @@ -121,7 +121,7 @@ SwAccessibleCell::SwAccessibleCell( SwAccessibleMap *pInitMap,
>  sal_Bool SwAccessibleCell::_InvalidateMyCursorPos()
>  {
>      sal_Bool bNew = IsSelected();
> -    sal_Bool bOld;
> +    sal_Bool bOld = sal_False;
>      {
>          osl::MutexGuard aGuard( aMutex );
>          bOld = bIsSelected;
This is good, but not necessary, because bOld is always initialized later.
Anyway, if it has any impact on performance, it's negative, because
there must be at least one instruction more (to store the initialization
value into the variable).

> @@ -349,7 +349,7 @@ sal_Bool SwAccessibleCell::setCurrentValue( const uno::Any& aNumber )
>      SolarMutexGuard aGuard;
>      CHECK_FOR_DEFUNC( XAccessibleValue );
>  
> -    double fValue = 0;
> +    const double fValue = 0;
>      sal_Bool bValid = (aNumber >>= fValue);
>      if( bValid )
>      {
This is absolutely wrong, because fValue is changed just a line lower (by
>>=, which is uno::Any extraction operator).

> diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx
> index 127820f..978dcad 100644
> --- a/sw/source/core/access/acccontext.cxx
> +++ b/sw/source/core/access/acccontext.cxx
> @@ -507,7 +507,7 @@ void SwAccessibleContext::FireVisibleDataEvent()
>  }
>  
>  void SwAccessibleContext::FireStateChangedEvent( sal_Int16 nState,
> -                                                 sal_Bool bNewState )
> +                                                 const sal_Bool bNewState )
>  {
>      AccessibleEventObject aEvent;
>  
This is good, but why not mark nState const as well? It is not changed
anywhere in the function... Anyway, there is absolutely _no_ performance
gain in it.

> -    void FireStateChangedEvent( sal_Int16 nState, sal_Bool bNewState );
> +    void FireStateChangedEvent( sal_Int16 nState, const sal_Bool
bNewState );
This is superfluous, because these two signatures are equal (well, not
all compilers understand it correctly, e.g., the Sun C++ compiler).

D.


More information about the LibreOffice mailing list