* prefer prefix increment operator unless logically necessary
  (it doesn't make any diff foro built-in type but good practice)
This commit is contained in:
artemp
2014-02-06 10:50:31 +00:00
parent a8fef83564
commit 2d3abf36b1
10 changed files with 16 additions and 18 deletions

View File

@@ -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<T> ref = *it;
if (ref.y == rect.y && ref.h == rect.h && ref.x + ref.w == rect.x) {
ref.w += rect.w;

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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<Tile::ID>& 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<Tile::ID> 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);
}
}

View File

@@ -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::ID> Tile::children(const ID& id, int32_t z) {
int32_t factor = pow(2, z - id.z);
std::forward_list<ID> 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);
}
}

View File

@@ -84,7 +84,7 @@ void FillBucket::addGeometry(const std::vector<Coordinate>& 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);
}

View File

@@ -93,7 +93,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& 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;

View File

@@ -131,7 +131,7 @@ void Painter::render(const Tile::Ptr& tile) {
void Painter::renderLayers(const std::shared_ptr<Tile>& tile, const std::vector<LayerDescription>& layers) {
// Render everything top-to-bottom by using reverse iterators
typedef std::vector<LayerDescription>::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()) {

View File

@@ -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));
}

View File

@@ -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<LayerDescription>& 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<std::string, ClassDescription>& 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 {