summaryrefslogtreecommitdiff
path: root/unity-shared
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 /unity-shared
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 'unity-shared')
-rw-r--r--unity-shared/BGHash.cpp2
-rw-r--r--unity-shared/DashStyle.cpp2
-rw-r--r--unity-shared/IconRenderer.cpp5
-rw-r--r--unity-shared/PluginAdapterCompiz.cpp2
4 files changed, 5 insertions, 6 deletions
diff --git a/unity-shared/BGHash.cpp b/unity-shared/BGHash.cpp
index 3ccd92e2f..767c8f377 100644
--- a/unity-shared/BGHash.cpp
+++ b/unity-shared/BGHash.cpp
@@ -155,7 +155,6 @@ nux::Color BGHash::MatchColor(nux::Color const& base_color) const
colors[10] = nux::Color (0x1b134c);
colors[11] = nux::Color (0x2c0d46);
- float closest_diff = 200.0f;
nux::Color chosen_color;
nux::color::HueSaturationValue base_hsv (base_color);
@@ -168,6 +167,7 @@ nux::Color BGHash::MatchColor(nux::Color const& base_color) const
}
else
{
+ float closest_diff = 200.0f;
LOG_DEBUG (logger) << "got a colour image";
// full colour image
for (int i = 0; i < 11; i++)
diff --git a/unity-shared/DashStyle.cpp b/unity-shared/DashStyle.cpp
index 789659139..31d997f0f 100644
--- a/unity-shared/DashStyle.cpp
+++ b/unity-shared/DashStyle.cpp
@@ -1648,7 +1648,6 @@ bool Style::SquareButton(cairo_t* cr, nux::ButtonVisualState state,
double height = h - (2.0 * garnish) - 1.0;
bool odd = true;
- double radius = 7.0;
// draw the grid background
{
@@ -1656,6 +1655,7 @@ bool Style::SquareButton(cairo_t* cr, nux::ButtonVisualState state,
cairo_move_to(cr, _align(x + width, odd), y);
if (curve_bottom)
{
+ double radius = 7.0;
LOG_DEBUG(logger) << "curve: " << _align(x + width, odd) << " - " << _align(y + height - radius, odd);
// line to bottom-right corner
cairo_line_to(cr, _align(x + width, odd), _align(y + height - radius, odd));
diff --git a/unity-shared/IconRenderer.cpp b/unity-shared/IconRenderer.cpp
index f8bbbba66..ed1fa65e6 100644
--- a/unity-shared/IconRenderer.cpp
+++ b/unity-shared/IconRenderer.cpp
@@ -250,7 +250,7 @@ void IconRenderer::PreprocessIcons(std::list<RenderArg>& args, nux::Geometry con
std::list<RenderArg>::iterator it;
int i;
- for (it = args.begin(), i = 0; it != args.end(); it++, i++)
+ for (it = args.begin(), i = 0; it != args.end(); ++it, i++)
{
IconTextureSource* launcher_icon = it->icon;
@@ -757,7 +757,6 @@ void IconRenderer::RenderElement(nux::GraphicsEngine& GfxContext,
CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
- int TextureObjectLocation;
int VertexLocation;
int TextureCoord0Location;
int FragmentColor = 0;
@@ -768,7 +767,7 @@ void IconRenderer::RenderElement(nux::GraphicsEngine& GfxContext,
{
local::shader_program_uv_persp_correction->Begin();
- TextureObjectLocation = local::shader_program_uv_persp_correction->GetUniformLocationARB("TextureObject0");
+ int TextureObjectLocation = local::shader_program_uv_persp_correction->GetUniformLocationARB("TextureObject0");
VertexLocation = local::shader_program_uv_persp_correction->GetAttributeLocation("iVertex");
TextureCoord0Location = local::shader_program_uv_persp_correction->GetAttributeLocation("iTexCoord0");
FragmentColor = local::shader_program_uv_persp_correction->GetUniformLocationARB("color0");
diff --git a/unity-shared/PluginAdapterCompiz.cpp b/unity-shared/PluginAdapterCompiz.cpp
index 567d37f49..057ccea0c 100644
--- a/unity-shared/PluginAdapterCompiz.cpp
+++ b/unity-shared/PluginAdapterCompiz.cpp
@@ -1010,7 +1010,7 @@ PluginAdapter::CheckWindowIntersections (nux::Geometry const& region, bool &acti
}
else
{
- for (it = window_list.begin(); it != window_list.end(); it++)
+ for (it = window_list.begin(); it != window_list.end(); ++it)
{
if (CheckWindowIntersection(region, *it))
{