Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualNightCreature83

Posted 28 January 2013 - 07:10 AM

You don't have to use the continue statement for this anyway if you rewrite the code as follows:

for(materials=0;materials<nrMaterials++materials)
{
    for(meshes=0;mesh<nrMeshes;++meshes)
    {
        if(materials[material].index[meshes].uses )
        {
            // otherwise do thing with this mesh
        }
   }
}

This is also more readable as you don't have an arbitrary jump in your code there, breaks and continue statements complicate the flow of your code as when you reread it you have to pay attention that you jump out of the current loop. Whilst my implementation allows you to read the thing in one go, and also there is only a true branch in this if which makes the logic far easier to follow.

#1NightCreature83

Posted 28 January 2013 - 06:14 AM

You don't have to use the continue statement for this anyway if you rewrite the code as follows:

[code=auto:0]

for(materials=0;materials<nrMaterials++materials)


{


    for(meshes=0;mesh<nrMeshes;++meshes)


    {

        if(materials[material].index[meshes].uses )

        {

            // otherwise do thing with this mesh

        }

    }


}

[\code]

 

This is also more readable as you don't have an arbitrary jump in your code there, breaks and continue statements complicate the flow of your code as when you reread it you have to pay attention that you jump out of the current loop. Whilst my implementation allows you to read the thing in one go, and also there is only a true branch in this if which makes the logic far easier to follow.


PARTNERS