Skip to content

Commit 2b50e06

Browse files
committed
Various small cleanups found by clang-tidy
1 parent cfaa039 commit 2b50e06

13 files changed

+28
-27
lines changed

src/expire-tiles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void expire_tiles::expire_tile(uint32_t x, uint32_t y)
116116
}
117117
}
118118

119-
uint32_t expire_tiles::normalise_tile_x_coord(int x)
119+
uint32_t expire_tiles::normalise_tile_x_coord(int x) const
120120
{
121121
x %= map_width;
122122
if (x < 0) {

src/expire-tiles.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
class reprojection;
2121
class table_t;
2222
class tile;
23+
2324
namespace ewkb {
2425
class parser_t;
25-
}
26+
} // namespace ewkb
2627

2728
/**
2829
* \brief Simple struct for the x and y index of a tile ID.
@@ -114,11 +115,10 @@ struct expire_tiles
114115
* (larger than largest possible quadkey). */
115116
uint64_t last_quadkey = 1ULL << (2 * maxzoom);
116117
std::size_t count = 0;
117-
for (std::vector<uint64_t>::const_iterator it = tiles_maxzoom.cbegin();
118-
it != tiles_maxzoom.cend(); ++it) {
118+
for (auto const quadkey : tiles_maxzoom) {
119119
for (uint32_t dz = 0; dz <= maxzoom - minzoom; ++dz) {
120120
// scale down to the current zoom level
121-
uint64_t qt_current = *it >> (dz * 2);
121+
uint64_t qt_current = quadkey >> (dz * 2);
122122
/* If dz > 0, there are propably multiple elements whose quadkey
123123
* is equal because they are all sub-tiles of the same tile at the current
124124
* zoom level. We skip all of them after we have written the first sibling.
@@ -130,7 +130,7 @@ struct expire_tiles
130130
output_writer.output_dirty_tile(xy.x, xy.y, maxzoom - dz);
131131
++count;
132132
}
133-
last_quadkey = *it;
133+
last_quadkey = quadkey;
134134
}
135135
log_info("Wrote {} entries to expired tiles list", count);
136136
}
@@ -178,7 +178,7 @@ struct expire_tiles
178178
* \param y y index of the tile to be expired.
179179
*/
180180
void expire_tile(uint32_t x, uint32_t y);
181-
uint32_t normalise_tile_x_coord(int x);
181+
uint32_t normalise_tile_x_coord(int x) const;
182182
void from_line(double lon_a, double lat_a, double lon_b, double lat_b);
183183

184184
void from_wkb_point(ewkb::parser_t *wkb);

src/geom.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ void split_linestring(linestring_t const &line, double split_at,
9595
dist = 0;
9696
prev_pt = this_pt;
9797
continue;
98-
} else {
99-
dist = distance(this_pt, ipoint);
10098
}
99+
dist = distance(this_pt, ipoint);
101100
} else {
102101
dist += delta;
103102
}

src/geom.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class linestring_t
6969

7070
void add_point(osmium::geom::Coordinates coordinates)
7171
{
72-
m_coordinates.emplace_back(std::move(coordinates));
72+
m_coordinates.emplace_back(coordinates);
7373
}
7474

7575
iterator begin() noexcept { return m_coordinates.begin(); }

src/osmdata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class multithreaded_processor
263263
* Runs in the worker threads: As long as there are any, get ids from
264264
* the queue and let the output process it by calling "func".
265265
*/
266-
static void run(std::shared_ptr<output_t> output, idlist_t *queue,
266+
static void run(std::shared_ptr<output_t> const &output, idlist_t *queue,
267267
std::mutex *mutex, output_member_fn_ptr func)
268268
{
269269
while (osmid_t const id = pop_id(queue, mutex)) {

src/osmtypes.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct member
4040

4141
explicit operator osmium::builder::attr::member_type() const
4242
{
43-
return osmium::builder::attr::member_type(type, id, role.c_str());
43+
return {type, id, role.c_str()};
4444
}
4545

4646
member(osmium::item_type t, osmid_t i, std::string r)
@@ -73,10 +73,9 @@ struct tag_t
7373
std::string key;
7474
std::string value;
7575

76-
operator std::pair<char const *, char const *>() const noexcept
76+
explicit operator std::pair<char const *, char const *>() const noexcept
7777
{
78-
return std::pair<char const *, char const *>(key.c_str(),
79-
value.c_str());
78+
return {key.c_str(), value.c_str()};
8079
}
8180

8281
tag_t(std::string k, std::string v) : key(std::move(k)), value(std::move(v))

src/output-flex.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,7 @@ static bool is_lua_array(lua_State *lua_state)
363363

364364
// An empty lua table could be both, we decide here that it is not stored
365365
// as a JSON array but as a JSON object.
366-
if (n == 1) {
367-
return false;
368-
}
369-
370-
return true;
366+
return n != 1;
371367
}
372368

373369
static void write_json(json_writer_type *writer, lua_State *lua_state,

src/output.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,21 @@ output_t::create_output(std::shared_ptr<middle_query_t> const &mid,
3838
if (options.output_backend == "pgsql") {
3939
return std::make_shared<output_pgsql_t>(mid, std::move(thread_pool),
4040
options, copy_thread);
41+
}
4142

4243
#ifdef HAVE_LUA
43-
} else if (options.output_backend == "flex") {
44+
if (options.output_backend == "flex") {
4445
return std::make_shared<output_flex_t>(mid, std::move(thread_pool),
4546
options, copy_thread);
47+
}
4648
#endif
4749

48-
} else if (options.output_backend == "gazetteer") {
50+
if (options.output_backend == "gazetteer") {
4951
return std::make_shared<output_gazetteer_t>(mid, std::move(thread_pool),
5052
options, copy_thread);
53+
}
5154

52-
} else if (options.output_backend == "null") {
55+
if (options.output_backend == "null") {
5356
return std::make_shared<output_null_t>(mid, std::move(thread_pool),
5457
options);
5558
}

src/reprojection-generic-proj6.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class generic_reprojection_t : public reprojection
9797

9898
auto const c_out = proj_trans(transformation, PJ_FWD, c_in);
9999

100+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access)
100101
return osmium::geom::Coordinates{c_out.xy.x, c_out.xy.y};
101102
}
102103

src/tagtransform-lua.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class lua_tagtransform_t : public tagtransform_t
2525

2626
public:
2727
explicit lua_tagtransform_t(options_t const *options);
28-
~lua_tagtransform_t();
28+
29+
~lua_tagtransform_t() override;
2930

3031
std::unique_ptr<tagtransform_t> clone() const override;
3132

0 commit comments

Comments
 (0)