~compiz-team/compiz/compiz.fix_1088399

« back to all changes in this revision

Viewing changes to plugins/wobbly/src/wobbly.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:
1218
1218
{
1219
1219
    float coeffsU[4], coeffsV[4];
1220
1220
    float x, y;
1221
 
    int   i, j;
1222
1221
 
1223
1222
    coeffsU[0] = (1 - u) * (1 - u) * (1 - u);
1224
1223
    coeffsU[1] = 3 * u * (1 - u) * (1 - u);
1232
1231
 
1233
1232
    x = y = 0.0f;
1234
1233
 
1235
 
    for (i = 0; i < 4; i++)
 
1234
    for (int i = 0; i < 4; i++)
1236
1235
    {
1237
 
        for (j = 0; j < 4; j++)
 
1236
        for (int j = 0; j < 4; j++)
1238
1237
        {
1239
1238
            x += coeffsU[i] * coeffsV[j] *
1240
1239
                objects[j * GRID_WIDTH + i].position.x;
1288
1287
{
1289
1288
    Object *object = &objects[0];
1290
1289
    float  distance, minDistance = 0.0;
1291
 
    int    i;
1292
1290
 
1293
 
    for (i = 0; i < numObjects; i++)
 
1291
    for (int i = 0; i < numObjects; i++)
1294
1292
    {
1295
1293
        distance = objects[i].distanceToPoint (x, y);
1296
1294
        if (i == 0 || distance < minDistance)
2054
2052
 
2055
2053
            if (wScreen->optionGetGrabWindowMatch ().evaluate (window))
2056
2054
            {
2057
 
                int i;
2058
 
                for (i = 0; i < model->numSprings; i++)
 
2055
                for (int i = 0; i < model->numSprings; i++)
2059
2056
                {
2060
2057
                    s = &model->springs[i];
2061
2058