~compiz-team/compiz/compiz.fix_1088399

« back to all changes in this revision

Viewing changes to plugins/scale/src/scale.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:
425
425
PrivateScaleScreen::layoutSlotsForArea (const CompRect& workArea,
426
426
                                        int             nWindows)
427
427
{
428
 
    int i, j;
 
428
    if (!nWindows)
 
429
        return;
 
430
 
429
431
    int x, y, width, height;
430
 
    int lines, n, nSlots;
431
 
    int spacing;
432
 
 
433
 
    if (!nWindows)
434
 
        return;
435
 
 
436
 
    lines   = sqrt (nWindows + 1);
437
 
    spacing = optionGetSpacing ();
438
 
    nSlots  = 0;
 
432
    int n;
 
433
 
 
434
    int lines   = sqrt (nWindows + 1);
 
435
    int spacing = optionGetSpacing ();
 
436
    int nSlots  = 0;
439
437
 
440
438
    y      = workArea.y () + spacing;
441
439
    height = (workArea.height () - (lines + 1) * spacing) / lines;
442
440
 
443
 
    for (i = 0; i < lines; i++)
 
441
    for (int i = 0; i < lines; i++)
444
442
    {
445
443
        n = MIN (nWindows - nSlots, ceilf ((float) nWindows / lines));
446
444
 
447
445
        x     = workArea.x () + spacing;
448
446
        width = (workArea.width () - (n + 1) * spacing) / n;
449
447
 
450
 
        for (j = 0; j < n; j++)
 
448
        for (int j = 0; j < n; j++)
451
449
        {
452
450
            slots[this->nSlots].setGeometry (x, y, width, height);
453
451
 
1493
1491
void
1494
1492
PrivateScaleScreen::windowRemove (CompWindow *w)
1495
1493
{
1496
 
    if (!w)
1497
 
        return;
1498
 
 
1499
 
    if (state == ScaleScreen::Idle || state == ScaleScreen::In)
 
1494
    if (!w || state == ScaleScreen::Idle || state == ScaleScreen::In)
1500
1495
        return;
1501
1496
 
1502
1497
    foreach (ScaleWindow *lw, windows)