From 2d3abf36b1978504ed4cc8406b3007389088d777 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 6 Feb 2014 10:50:31 +0000 Subject: [PATCH] c++ * prefer prefix increment operator unless logically necessary (it doesn't make any diff foro built-in type but good practice) --- include/llmr/geometry/binpack.hpp | 2 +- include/llmr/util/unitbezier.hpp | 2 +- src/geometry/debug_font_buffer.cpp | 2 +- src/map/map.cpp | 6 +++--- src/map/tile.cpp | 6 +++--- src/renderer/fill_bucket.cpp | 4 +--- src/renderer/line_bucket.cpp | 2 +- src/renderer/painter.cpp | 2 +- src/style/sprite.cpp | 2 +- src/style/style.cpp | 6 +++--- 10 files changed, 16 insertions(+), 18 deletions(-) diff --git a/include/llmr/geometry/binpack.hpp b/include/llmr/geometry/binpack.hpp index d7405d7d3..53b9e6c1a 100644 --- a/include/llmr/geometry/binpack.hpp +++ b/include/llmr/geometry/binpack.hpp @@ -69,7 +69,7 @@ public: // Simple algorithm to recursively merge the newly released cell with its // neighbor. This doesn't merge more than two cells at a time, and fails // for complicated merges. - for (auto it = free.begin(); it != free.end(); it++) { + for (auto it = free.begin(); it != free.end(); ++it) { Rect ref = *it; if (ref.y == rect.y && ref.h == rect.h && ref.x + ref.w == rect.x) { ref.w += rect.w; diff --git a/include/llmr/util/unitbezier.hpp b/include/llmr/util/unitbezier.hpp index e64f7abd4..6acae7a3d 100644 --- a/include/llmr/util/unitbezier.hpp +++ b/include/llmr/util/unitbezier.hpp @@ -66,7 +66,7 @@ struct UnitBezier { int i; // First try a few iterations of Newton's method -- normally very fast. - for (t2 = x, i = 0; i < 8; i++) { + for (t2 = x, i = 0; i < 8; ++i) { x2 = sampleCurveX(t2) - x; if (fabs (x2) < epsilon) return t2; diff --git a/src/geometry/debug_font_buffer.cpp b/src/geometry/debug_font_buffer.cpp index ba180ff60..976c59323 100644 --- a/src/geometry/debug_font_buffer.cpp +++ b/src/geometry/debug_font_buffer.cpp @@ -22,7 +22,7 @@ DebugFontBuffer::~DebugFontBuffer() { void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) { int32_t length = strlen(text); - for (int32_t i = 0; i < length; i++) { + for (int32_t i = 0; i < length; ++i) { if (text[i] < 32 || text[i] > 127) { continue; } diff --git a/src/map/map.cpp b/src/map/map.cpp index 2828b9d9b..cc028496b 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -222,7 +222,7 @@ bool Map::findLoadedChildren(const Tile::ID& id, int32_t maxCoveringZoom, std::f * @return boolean Whether a parent was found. */ bool Map::findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std::forward_list& retain) { - for (int32_t z = id.z - 1; z >= minCoveringZoom; z--) { + for (int32_t z = id.z - 1; z >= minCoveringZoom; --z) { const Tile::ID parent_id = Tile::parent(id, z); const Tile::Ptr tile = hasTile(parent_id); if (tile && tile->state == Tile::ready) { @@ -263,8 +263,8 @@ void Map::updateTiles() { // TODO: Discard tiles that are outside the viewport std::forward_list required; - for (int32_t y = tl.y; y < br.y; y++) { - for (int32_t x = tl.x; x < br.x; x++) { + for (int32_t y = tl.y; y < br.y; ++y) { + for (int32_t x = tl.x; x < br.x; ++x) { required.emplace_front(x, y, zoom); } } diff --git a/src/map/tile.cpp b/src/map/tile.cpp index f274d0244..da0ad0006 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -17,7 +17,7 @@ Tile::ID Tile::parent(const ID& id, int32_t z) { assert(z < id.z); ID pos(id); while (pos.z > z) { - pos.z--; + --pos.z; pos.x = floor(pos.x / 2); pos.y = floor(pos.y / 2); } @@ -30,8 +30,8 @@ std::forward_list Tile::children(const ID& id, int32_t z) { int32_t factor = pow(2, z - id.z); std::forward_list children; - for (int32_t y = id.y * factor, y_max = (id.y + 1) * factor; y < y_max; y++) { - for (int32_t x = id.x * factor, x_max = (id.x + 1) * factor; x < x_max; x++) { + for (int32_t y = id.y * factor, y_max = (id.y + 1) * factor; y < y_max; ++y) { + for (int32_t x = id.x * factor, x_max = (id.x + 1) * factor; x < x_max; ++x) { children.emplace_front(x, y, z); } } diff --git a/src/renderer/fill_bucket.cpp b/src/renderer/fill_bucket.cpp index 6815efb6f..a45852ebf 100644 --- a/src/renderer/fill_bucket.cpp +++ b/src/renderer/fill_bucket.cpp @@ -84,7 +84,7 @@ void FillBucket::addGeometry(const std::vector& line) { uint32_t elements_start = buffer.elements_length(); - for (uint32_t i = 2; i < vertex_count; i++) { + for (uint32_t i = 2; i < vertex_count; ++i) { buffer.addElements(firstIndex, firstIndex + i - 1, firstIndex + i); } @@ -122,5 +122,3 @@ void FillBucket::drawVertices(OutlineShader& shader) { array.bind(shader, *buffer, vertex_index); glDrawArrays(GL_LINE_STRIP, 0, length); } - - diff --git a/src/renderer/line_bucket.cpp b/src/renderer/line_bucket.cpp index 970f6ad38..ccefdf256 100644 --- a/src/renderer/line_bucket.cpp +++ b/src/renderer/line_bucket.cpp @@ -93,7 +93,7 @@ void LineBucket::addGeometry(const std::vector& vertices) { // Start all lines with a degenerate vertex buffer->addDegenerate(); - for (size_t i = 0; i < vertices.size(); i++) { + for (size_t i = 0; i < vertices.size(); ++i) { if (nextNormal) prevNormal = { -nextNormal.x, -nextNormal.y }; if (currentVertex) prevVertex = currentVertex; diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 22cb58368..31f8a8333 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -131,7 +131,7 @@ void Painter::render(const Tile::Ptr& tile) { void Painter::renderLayers(const std::shared_ptr& tile, const std::vector& layers) { // Render everything top-to-bottom by using reverse iterators typedef std::vector::const_reverse_iterator iterator; - for (iterator it = layers.rbegin(), end = layers.rend(); it != end; it++) { + for (iterator it = layers.rbegin(), end = layers.rend(); it != end; ++it) { const LayerDescription& layer_desc = *it; if (layer_desc.child_layer.size()) { diff --git a/src/style/sprite.cpp b/src/style/sprite.cpp index 675deb27e..a37b31f93 100644 --- a/src/style/sprite.cpp +++ b/src/style/sprite.cpp @@ -180,7 +180,7 @@ void Sprite::loadImage(const std::string& data) { assert(surface); png_bytep row_pointers[height]; - for (unsigned i = 0; i < height; i++) { + for (unsigned i = 0; i < height; ++i) { row_pointers[i] = (png_bytep)(surface + (i * rowbytes)); } diff --git a/src/style/style.cpp b/src/style/style.cpp index 85c85b979..0e8e9f3b6 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -322,7 +322,7 @@ BucketDescription loadBucketJSON(const rapidjson::Value& value) { } } else if (name == "value") { if (value.IsArray()) { - for (rapidjson::SizeType i = 0; i < value.Size(); i++) { + for (rapidjson::SizeType i = 0; i < value.Size(); ++i) { bucket.source_value.push_back(loadValueJSON(value[i])); } } else { @@ -361,7 +361,7 @@ BucketDescription loadBucketJSON(const rapidjson::Value& value) { void loadLayersJSON(const rapidjson::Value& value, std::vector& layers) { if (value.IsArray()) { - for (rapidjson::SizeType i = 0; i < value.Size(); i++) { + for (rapidjson::SizeType i = 0; i < value.Size(); ++i) { layers.push_back(loadLayerJSON(value[i])); } } else { @@ -407,7 +407,7 @@ LayerDescription loadLayerJSON(const rapidjson::Value& value) { void loadClassesJSON(const rapidjson::Value& value, std::map& classes) { if (value.IsArray()) { - for (rapidjson::SizeType i = 0; i < value.Size(); i++) { + for (rapidjson::SizeType i = 0; i < value.Size(); ++i) { classes.insert(loadClassDescriptionJSON(value[i])); } } else {