~sciso/compiz/compiz

« back to all changes in this revision

Viewing changes to plugins/animation/src/extensionplugin.cpp

Fixed various problems described in bug 1030473.
Optimized performance and style following suggestions reported by cppcheck:

1. Used !xxxx.empty() instead of xxxx.size(), because it can be faster. xxxx.size() can take linear time while xxxx.empty() is guaranteed to take constant time.

2. Defensive programming: Reordered array-out-of-bound condition checks such as '(a[i] && i < 10)' to '(i < 10 && a[i])'. That way the array will not be accessed, because the index is checked first.. Fixes: . Approved by Daniel van Vugt, Sam Spilsbury.

Show diffs side-by-side

added added

removed removed

Lines of Context:
432
432
                wEnd = wRestacked;
433
433
                wOldAbove = wStart;
434
434
            }
435
 
            else if (clients[(unsigned)changeStart] ==
436
 
                     mLastClientList[(unsigned)changeEnd] && // lowered
 
435
            else if ((unsigned int)changeEnd < n - 1 &&
 
436
                     clients[(unsigned)changeStart] ==
 
437
                     mLastClientList[(unsigned)changeEnd]) // lowered
437
438
                     // We don't animate lowering if there is no
438
439
                     // window above this window, since this window needs
439
440
                     // to be drawn on such a "host" in animPaintWindow
440
441
                     // (at least for now).
441
 
                     (unsigned int)changeEnd < n - 1)
442
442
            {
443
443
                wRestacked = wChangeStart;
444
444
                wStart = wRestacked;