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

Kayo Hamid kayo.hamid at gekkolinux.com.br
Sat Jan 8 15:04:20 PST 2011

On 08/01/2011 17:00, Norbert Thiebaud wrote:
> I' confused:
> -    sal_Int32 nCount = xAcc->getAccessibleChildCount();
> -
> -    for( sal_Int32 i=0; i<  nCount; i++ )
> +    const sal_Int32 nCount = xAcc->getAccessibleChildCount();
> +    sal_Int32 i = 0;
> +	
> +    while(i<  nCount)
>       {
> -        if( xAcc->getAccessibleChild( i ) == xThis )
> -            return i;
> +	    if( xAcc->getAccessibleChild( i ) == xThis )
> +		    return i;
> +	    i++;
>       }
> +
> Unless I'm really dense: this simply change a for() loop into a
> while() loop doing exactly the same thing
> Why is it supposed to improve performance ?
> as for the rest:
> Did you really measure that turning a passed-by-value scalar (which
> caller's value cannot be modified by the callee, by definition) into a
> const passed by value
>   scalar, has _actually_ any performance impact ?
> Norbert
Hello Norbert, first of all i'm new at coding, I really do not know if 
we have any improve, but after looking a lot for c++ performance tips 
(and I continue looking and reading tips for that) I have in my mind 
some things like:

for/while -> it's better to use while, it's not a huge improve, but you 
can find tips that say 'use while, it's better'. I just do it.

const -> my goal is to change the local variable to const is to put it 
in read-only, wich is better, but in that case that we receive 
pass-by-value, is my fault.  The problem is that i do not known that 
this method returns reference.

It's because all this that I ask for one review, I want to learn with 
everyone here. I'm in the right way? My goal is to code things that are 
better, even with minimal improves.


More information about the LibreOffice mailing list