summaryrefslogtreecommitdiff
path: root/plugins
diff options
authorMC Return <mc.return@gmx.net>2012-08-03 07:58:29 -0400
committerTarmac <>2012-08-03 07:58:29 -0400
commita2fb98d9f5751252f1df0b65945522981670ce8f (patch)
tree97612755568e3802fe7b290ff403080765053fbe /plugins
parent68648f44e4fe6ad89c75f1ab7057e8b680f03922 (diff)
parentb3e22bce0ac9e368c76ad7bbbe22230991e51c71 (diff)
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: . Approved by Brandon Schaefer, Marco Trevisan (TreviƱo). (bzr r2534)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp2
-rw-r--r--plugins/unitydialog/src/unitydialog.cpp7
-rw-r--r--plugins/unityshell/src/nux-layout-accessible.cpp2
-rw-r--r--plugins/unityshell/src/unity-launcher-accessible.cpp2
-rw-r--r--plugins/unityshell/src/unity-switcher-accessible.cpp2
-rw-r--r--plugins/unityshell/src/unityshell.cpp8
6 files changed, 10 insertions, 13 deletions
diff --git a/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp b/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp
index 74bd70d7c..ad840204c 100644
--- a/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp
+++ b/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp
@@ -292,7 +292,7 @@ UnityMTGrabHandlesScreen::handleEvent(XEvent* event)
CompWindowVector::const_iterator cit = clientListStacking.begin();
CompWindowVector::const_iterator oit = mLastClientListStacking.begin();
- for (; cit != clientListStacking.end(); cit++, oit++)
+ for (; cit != clientListStacking.end(); ++cit, oit++)
{
/* All clients from this point onwards in cit are invalidated
* so splice the list to the end of the new client list
diff --git a/plugins/unitydialog/src/unitydialog.cpp b/plugins/unitydialog/src/unitydialog.cpp
index 05b51ddc6..91f7f235e 100644
--- a/plugins/unitydialog/src/unitydialog.cpp
+++ b/plugins/unitydialog/src/unitydialog.cpp
@@ -367,7 +367,7 @@ UnityDialogScreen::donePaint()
continue;
}
- it++;
+ ++it;
}
}
@@ -1383,7 +1383,6 @@ UnityDialogWindow::place(CompPoint& pos)
CompWindow::Geometry transientGeometry;
CompRegion transientPos, outputRegion, outsideArea, outsideRegion;
pos = getChildCenteredPositionForRect(mParent->serverBorderRect());
- int hdirection, vdirection;
transientGeometry = CompWindow::Geometry(pos.x(),
pos.y(),
@@ -1406,8 +1405,8 @@ UnityDialogWindow::place(CompPoint& pos)
int width;
int height;
- hdirection = outsideArea.boundingRect().x() < 0 ? 1 : -1;
- vdirection = outsideArea.boundingRect().y() < 0 ? 1 : -1;
+ int hdirection = outsideArea.boundingRect().x() < 0 ? 1 : -1;
+ int vdirection = outsideArea.boundingRect().y() < 0 ? 1 : -1;
width = outsideArea.boundingRect().width() >=
window->serverBorderRect().width() ? 0 :
diff --git a/plugins/unityshell/src/nux-layout-accessible.cpp b/plugins/unityshell/src/nux-layout-accessible.cpp
index 8bec1d9e2..d692c696e 100644
--- a/plugins/unityshell/src/nux-layout-accessible.cpp
+++ b/plugins/unityshell/src/nux-layout-accessible.cpp
@@ -203,7 +203,7 @@ search_for_child(AtkObject* accessible,
element_list = layout->GetChildren();
- for (it = element_list.begin(); it != element_list.end(); it++, result++)
+ for (it = element_list.begin(); it != element_list.end(); ++it, result++)
{
current_area = *it;
if (current_area == area)
diff --git a/plugins/unityshell/src/unity-launcher-accessible.cpp b/plugins/unityshell/src/unity-launcher-accessible.cpp
index d20deed28..4cb4301ae 100644
--- a/plugins/unityshell/src/unity-launcher-accessible.cpp
+++ b/plugins/unityshell/src/unity-launcher-accessible.cpp
@@ -441,7 +441,7 @@ update_children_index(UnityLauncherAccessible* self)
if (launcher_model == NULL)
return;
- for (it = launcher_model->begin(); it != launcher_model->end(); it++)
+ for (it = launcher_model->begin(); it != launcher_model->end(); ++it)
{
child = dynamic_cast<nux::Object*>((*it).GetPointer());
child_accessible = unity_a11y_get_accessible(child);
diff --git a/plugins/unityshell/src/unity-switcher-accessible.cpp b/plugins/unityshell/src/unity-switcher-accessible.cpp
index e4e2a968f..189e7d703 100644
--- a/plugins/unityshell/src/unity-switcher-accessible.cpp
+++ b/plugins/unityshell/src/unity-switcher-accessible.cpp
@@ -404,7 +404,7 @@ create_children(UnitySwitcherAccessible* self)
if (switcher_model == NULL)
return;
- for (it = switcher_model->begin(); it != switcher_model->end(); it++)
+ for (it = switcher_model->begin(); it != switcher_model->end(); ++it)
{
child = *it;
child_accessible = unity_launcher_icon_accessible_new(child.GetPointer());
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp
index 90ae1a627..999466b84 100644
--- a/plugins/unityshell/src/unityshell.cpp
+++ b/plugins/unityshell/src/unityshell.cpp
@@ -1211,7 +1211,7 @@ bool UnityScreen::shellCouldBeHidden(CompOutput const& output)
CompWindowList const& wins = screen->windows();
for ( CompWindowList::const_reverse_iterator r = wins.rbegin()
; r != wins.rend()
- ; r++
+ ; ++r
)
{
CompWindow* w = *r;
@@ -1309,10 +1309,9 @@ void UnityScreen::glPaintCompositedOutput (const CompRegion &region,
::GLFramebufferObject *fbo,
unsigned int mask)
{
- bool useFbo = false;
-
if (doShellRepaint)
{
+ bool useFbo = false;
oldFbo = fbo->bind ();
useFbo = fbo->checkStatus () && fbo->tex ();
if (!useFbo) {
@@ -2167,10 +2166,9 @@ bool UnityScreen::ShowHudInitiate(CompAction* action,
{
// Look to see if there is a keycode. If there is, then this isn't a
// modifier only keybinding.
- int key_code = 0;
if (options[6].type() != CompOption::TypeUnset)
{
- key_code = options[6].value().i();
+ int key_code = options[6].value().i();
LOG_DEBUG(logger) << "HUD initiate key code: " << key_code;
// show it now, no timings or terminate needed.
return ShowHud();