summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/los.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2011-07-04 23:54:32 +0200
committerAdam Borowski <kilobyte@angband.pl>2011-07-05 02:23:41 +0200
commite4066ccd619b59a64c6fc9643a478fa7ef72f600 (patch)
tree949c30d9c926395a397e70f0a5ffcedb6edff9ac /crawl-ref/source/los.cc
parent06bb5b5c8199203001e4b3479351adf321299be5 (diff)
downloadcrawl-ref-e4066ccd619b59a64c6fc9643a478fa7ef72f600.tar.gz
crawl-ref-e4066ccd619b59a64c6fc9643a478fa7ef72f600.zip
cppcheck: use ++p not p++ for complex types (like iterators).
Pre-increment looks worse than post-increment, but on a C++ object the latter forces an allocation plus copy that is completely unnecessary but the compiler doesn't know that yet. Note that I did change some of our iterators to return void rather than the old or new value for exactly this performance reason before, breaking the expected behaviour. If that's an issue, tell me, we can use preincrements instead which have very little penalty.
Diffstat (limited to 'crawl-ref/source/los.cc')
-rw-r--r--crawl-ref/source/los.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/crawl-ref/source/los.cc b/crawl-ref/source/los.cc
index 4047823368..f2c9504bdd 100644
--- a/crawl-ref/source/los.cc
+++ b/crawl-ref/source/los.cc
@@ -118,7 +118,7 @@ void clear_rays_on_exit()
{
delete dead_rays;
delete smoke_rays;
- for (quadrant_iterator qi; qi; qi++)
+ for (quadrant_iterator qi; qi; ++qi)
delete blockrays(*qi);
}
@@ -356,7 +356,7 @@ static std::vector<int> _find_minimal_cellrays()
break;
}
if (!erased)
- min_it++;
+ ++min_it;
else
erased = false;
}
@@ -366,10 +366,10 @@ static std::vector<int> _find_minimal_cellrays()
}
std::vector<int> result;
- for (quadrant_iterator qi; qi; qi++)
+ for (quadrant_iterator qi; qi; ++qi)
{
std::list<cellray>& min = minima(*qi);
- for (min_it = min.begin(); min_it != min.end(); min_it++)
+ for (min_it = min.begin(); min_it != min.end(); ++min_it)
{
// Calculate imbalance and slope difference for sorting.
min_it->calc_params();
@@ -404,7 +404,7 @@ static void _create_blockrays()
// cell in ray_coords.
const int n_cellrays = ray_coords.size();
blockrays_t all_blockrays;
- for (quadrant_iterator qi; qi; qi++)
+ for (quadrant_iterator qi; qi; ++qi)
all_blockrays(*qi) = new bit_array(n_cellrays);
for (unsigned int r = 0; r < fullrays.size(); ++r)
@@ -430,7 +430,7 @@ static void _create_blockrays()
cellray_ends[i] = ray_coords[min_indices[i]];
// Compress blockrays accordingly.
- for (quadrant_iterator qi; qi; qi++)
+ for (quadrant_iterator qi; qi; ++qi)
{
blockrays(*qi) = new bit_array(n_min_rays);
for (int i = 0; i < n_min_rays; ++i)
@@ -439,7 +439,7 @@ static void _create_blockrays()
}
// We can throw away all_blockrays now.
- for (quadrant_iterator qi; qi; qi++)
+ for (quadrant_iterator qi; qi; ++qi)
delete all_blockrays(*qi);
dead_rays = new bit_array(n_min_rays);
@@ -811,7 +811,7 @@ static void _losight_quadrant(los_grid& sh, const los_param& dat, int sx, int sy
dead_rays->reset();
smoke_rays->reset();
- for (quadrant_iterator qi; qi; qi++)
+ for (quadrant_iterator qi; qi; ++qi)
{
coord_def p = coord_def(sx*(qi->x), sy*(qi->y));
if (!dat.los_bounds(p))