[Libreoffice] code simplification: please logic review, to be sure

Pierre-André Jacquod pjacquod at alumni.ethz.ch
Fri Aug 26 13:23:07 PDT 2011


Hello,
I am trying to wipe some unneeded calls and I see the following:

while( xxxx )
{
         -----
         SwFrm* pFrm;
         if( 0 != ( pONd = aIdx.GetNode().GetOLENode() ) &&
             aName.Equals( pONd->GetChartTblName() ) &&
             0 != ( pFrm = pONd->getLayoutFrm( rVSh.GetLayout() ) ) )
         {....
         }
         ...
}

knowing that pFrm is never used execpt in the comparision, I wanted to 
simplify to :
    0 != ( pONd->getLayoutFrm( rVSh.GetLayout() )
since the return value of the operator= should be the same as the right 
operand.

But this basically, this just ensure that the return value is not NULL 
(comparing the pointer SwFrm* with 0 )

So I though the final version to be:
if( 0 != ( pONd = aIdx.GetNode().GetOLENode() ) &&
             aName.Equals( pONd->GetChartTblName() ) &&
             pONd->getLayoutFrm( rVSh.GetLayout()         )
         {....
         }

Did I missed something with my logic ?

The code is from line 145 of sw/source/core/doc/docchart.cxx

Thanks a lot for your feed-back

best regards
Pierre-André


More information about the LibreOffice mailing list