~compiz-team/compiz/compiz.fix_1088399

« back to all changes in this revision

Viewing changes to plugins/cube/src/cube.cpp

Minor Performance Optimizations:

* Return ASAP./Prevent executing any unnecessary operations if we return.
* Used De Morgan's laws to merge and simplify if statements.

Other Changes:

* C++ Style: Declared iterator variables inside the for loops they are used in.
* No logic changes have been made.

Approved by Daniel van Vugt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
444
444
{
445
445
    const GLfloat angle = 2 * M_PI / (GLfloat) ((n == 0) ? 1 : n);
446
446
    const int     size = abs (n);
447
 
    int           i;
448
447
 
449
448
    *ppSint = (GLfloat *) calloc (sizeof (GLfloat), size + 1);
450
449
    *ppCost = (GLfloat *) calloc (sizeof (GLfloat), size + 1);
460
459
    (*ppSint)[0] = 0.0;
461
460
    (*ppCost)[0] = 1.0;
462
461
 
463
 
    for (i = 1; i < size; i++)
 
462
    for (int i = 1; i < size; i++)
464
463
    {
465
464
        (*ppSint)[i] = sin (angle * i);
466
465
        (*ppCost)[i] = cos (angle * i);
489
488
    GLfloat x;
490
489
    GLfloat y;
491
490
    GLfloat z;
492
 
    int     i;
493
 
    int     j;
494
491
    int     iStacksStart;
495
492
    int     iStacksEnd;
496
493
    int     iSlicesStart;
548
545
 
549
546
    glBegin (GL_QUADS);
550
547
 
551
 
    for (i = iStacksStart; i < iStacksEnd; i++)
 
548
    for (int i = iStacksStart; i < iStacksEnd; i++)
552
549
    {
553
550
        afTexCoordX[0] = 1.0f;
554
551
        afTexCoordX[1] = 1.0f - fStepX;
555
552
        afTexCoordX[2] = 1.0f - fStepX;
556
553
        afTexCoordX[3] = 1.0f;
557
554
 
558
 
        for (j = iSlicesStart; j < iSlicesEnd; j++)
 
555
        for (int j = iSlicesStart; j < iSlicesEnd; j++)
559
556
        {
560
557
            /* bottom-right */
561
558
            z = cost2[i];
896
893
                                         PaintOrder                paintOrder,
897
894
                                         int                       dx)
898
895
{
899
 
    int output;
900
 
 
901
896
    if (!cubeScreen->cubeShouldPaintViewport (sAttrib, transform, outputPtr, 
902
897
                                              paintOrder))
903
898
        return;
904
899
 
905
 
    output = ((unsigned int) outputPtr->id () != (unsigned int) ~0)
 
900
    int output = ((unsigned int) outputPtr->id () != (unsigned int) ~0)
906
901
                                                         ? outputPtr->id () : 0;
907
902
 
908
903
    mPaintOrder = paintOrder;
968
963
{
969
964
    GLScreenPaintAttrib sa = sAttrib;
970
965
 
971
 
    int i;
972
966
    int xMoveAdd;
973
967
    int origXMoveAdd = 0; /* dx for the viewport we start
974
968
                             painting with (back-most). */
1003
997
            iFirstSign = 1;
1004
998
    }
1005
999
 
1006
 
    for (i = 0; i <= hsize / 2; i++)
 
1000
    for (int i = 0; i <= hsize / 2; i++)
1007
1001
    {
1008
1002
        /* move to the correct viewport (back to front). */
1009
1003
        xMoveAdd = origXMoveAdd;        /* move to farthest viewport. */