~timo-jyrinki/compiz/metacity-key-migrations

« back to all changes in this revision

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

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

1. Reduced the scope of various variables.

2. Used prefix ++ operators for non-primitive types, because those can be more efficient than post-increment. Post-increment usually keeps a copy of the previous value, adds extra code and is slower.. Fixes: https://bugs.launchpad.net/bugs/1030473. Approved by Daniel van Vugt, Sam Spilsbury.

Show diffs side-by-side

added added

removed removed

Lines of Context:
609
609
    updateState (0),
610
610
    mPixmapReceiver (requestor, this)
611
611
{
612
 
    int             left, right, top, bottom;
613
612
    int             x1, y1, x2, y2;
614
613
 
615
614
    if (!texture && type == WINDOW_DECORATION_TYPE_PIXMAP)
620
619
 
621
620
    if (type == WINDOW_DECORATION_TYPE_PIXMAP)
622
621
    {
623
 
        left   = 0;
624
 
        right  = minWidth;
625
 
        top    = 0;
626
 
        bottom = minHeight;
 
622
        int left = 0, right = minWidth, top = 0, bottom = minHeight;
627
623
 
628
624
        for (unsigned int i = 0; i  < nQuad; i++)
629
625
        {
835
831
            Decoration::Ptr d = Decoration::create (id, prop, n, type, i, requestor);
836
832
 
837
833
            /* Try to replace an existing decoration */
838
 
            for (; it != mList.end (); it++)
 
834
            for (; it != mList.end (); ++it)
839
835
            {
840
836
                if ((*it)->frameType == d->frameType &&
841
837
                    (*it)->frameState == d->frameState &&
884
880
                std::list <Decoration::Ptr>::iterator it = mList.begin ();
885
881
 
886
882
                /* Use an existing decoration */
887
 
                for (; it != mList.end (); it++)
 
883
                for (; it != mList.end (); ++it)
888
884
                {
889
885
                    if ((*it)->frameType == frameType &&
890
886
                        (*it)->frameState == frameState &&
1340
1336
                cit = mList.begin ();
1341
1337
 
1342
1338
        for (std::list <Decoration::Ptr>::iterator it = mList.begin ();
1343
 
             it != mList.end (); it++)
 
1339
             it != mList.end (); ++it)
1344
1340
        {
1345
1341
            const Decoration::Ptr &d = *it;
1346
1342