[Libreoffice] Possible little code simplification

Michael Stahl mstahl at redhat.com
Thu Nov 24 14:11:55 PST 2011


On 24/11/11 19:07, Ivan Timofeev wrote:
> Hi all,
> 
> we have the field 'SwSortedObjs* pSortedObjs' in the class SwPageFrm.
> And we have the strange management of it:
> 
> For example, sw/source/core/layout/flylay.cxx:734
> 
>     if ( pSortedObjs )
>     {
>         pSortedObjs->Remove( *pToRemove );
>         if ( !pSortedObjs->Count() )
>         {   DELETEZ( pSortedObjs );
>         }
>     }
> 
> i.e. we delete pSortedObjs every time it is empty, and create it again
> when we want to add something into it. This entails annoying checks,
> like
> 
>     if ( pPage->GetSortedObjs() )
>         // [loop over pSortedObjs]
> 
> What do you think about changing the code so that pSortedObjs will be
> alive every time? We will be able to return a reference to pSortedObjs
> in GetSortedObjs() instead of a pointer and remove the mentioned
> checks (there are a lot of such checks). I could do this. :-)

the writer core and layout code is highly optimized, especially for
16-bit windows where memory is scarce :)

i guess for SwPageFrm it doesn't matter at all if the SwSortedObj always
exists.

> Same problem with the field 'SwSortedObjs* pDrawObjs' in the class SwFrm.

since this is the base class of all frames there will be a couple more
instances of it, and most of these probably won't use pDrawObjs; would
be interesting to know how much memory this would uses for a large
document...

> All the best,
>     Ivan




More information about the LibreOffice mailing list