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

« back to all changes in this revision

Viewing changes to plugins/session/src/session.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:
200
200
                              const char *prop)
201
201
{
202
202
    xmlChar *temp;
203
 
    int     num;
204
203
 
205
204
    temp = xmlGetProp (node, BAD_CAST prop);
206
205
    if (temp)
207
206
    {
208
 
        num = xmlXPathCastStringToNumber (temp);
 
207
        int num = xmlXPathCastStringToNumber (temp);
209
208
        xmlFree (temp);
210
209
 
211
210
        return num;
267
266
{
268
267
    CompString clientId, command, string;
269
268
    CompString resName, resClass;
270
 
    int        x, y, width, height;
271
269
    xmlNodePtr node, childNode;
272
270
 
273
271
    if (!getClientLeaderProperty (w, clientIdAtom, clientId) &&
308
306
    childNode = xmlNewChild (node, NULL, BAD_CAST "geometry", NULL);
309
307
    if (childNode)
310
308
    {
311
 
        x = (w->saveMask () & CWX) ? w->saveWc ().x : w->serverX ();
312
 
        y = (w->saveMask () & CWY) ? w->saveWc ().y : w->serverY ();
 
309
        int x = (w->saveMask () & CWX) ? w->saveWc ().x : w->serverX ();
 
310
        int y = (w->saveMask () & CWY) ? w->saveWc ().y : w->serverY ();
313
311
        if (!w->onAllViewports ())
314
312
        {
315
313
            x += screen->vp ().x () * screen->width ();
319
317
        x -= w->border ().left;
320
318
        y -= w->border ().top;
321
319
 
322
 
        width  = (w->saveMask () & CWWidth) ? w->saveWc ().width :
 
320
        int width  = (w->saveMask () & CWWidth) ? w->saveWc ().width :
323
321
                                          w->serverWidth ();
324
 
        height = (w->saveMask () & CWHeight) ? w->saveWc ().height :
 
322
        int height = (w->saveMask () & CWHeight) ? w->saveWc ().height :
325
323
                                           w->serverHeight ();
326
324
 
327
325
        addIntegerPropToNode (childNode, "x", x);
502
500
    getWindowTitle (w->id (), title);
503
501
    getTextProperty (w->id (), roleAtom, role);
504
502
 
505
 
    for (item = items.begin (); item != items.end (); item++)
 
503
    for (item = items.begin (); item != items.end (); ++item)
506
504
    {
507
505
        if (!clientId.empty () && clientId == item->clientId)
508
506
        {