Skip to content

Commit a1c1f3c

Browse files
authored
Merge pull request #2350 from joto/constness
Various cleanups around "const"
2 parents cfbdf83 + fec8513 commit a1c1f3c

32 files changed

+85
-85
lines changed

src/db-copy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void db_deleter_by_id_t::delete_rows(std::string const &table,
3131
fmt::format_to(std::back_inserter(sql),
3232
FMT_STRING("DELETE FROM {} WHERE {} IN ("), table, column);
3333

34-
for (auto id : m_deletables) {
34+
for (auto const id : m_deletables) {
3535
format_to(std::back_inserter(sql), FMT_STRING("{},"), id);
3636
}
3737
sql[sql.size() - 1] = ')';

src/expire-tiles.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ quadkey_list_t expire_tiles::get_tiles()
270270
{
271271
quadkey_list_t tiles;
272272
tiles.reserve(m_dirty_tiles.size());
273-
tiles.assign(m_dirty_tiles.begin(), m_dirty_tiles.end());
273+
tiles.assign(m_dirty_tiles.cbegin(), m_dirty_tiles.cend());
274274
std::sort(tiles.begin(), tiles.end());
275275
m_dirty_tiles.clear();
276276
return tiles;
@@ -288,8 +288,8 @@ void expire_tiles::merge_and_destroy(expire_tiles *other)
288288
using std::swap;
289289
swap(m_dirty_tiles, other->m_dirty_tiles);
290290
} else {
291-
m_dirty_tiles.insert(other->m_dirty_tiles.begin(),
292-
other->m_dirty_tiles.end());
291+
m_dirty_tiles.insert(other->m_dirty_tiles.cbegin(),
292+
other->m_dirty_tiles.cend());
293293
other->m_dirty_tiles.clear();
294294
}
295295
}

src/gen/osm2pgsql-gen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777
namespace {
7878

79-
constexpr std::size_t const MAX_FORCE_SINGLE_THREAD = 4;
79+
constexpr std::size_t MAX_FORCE_SINGLE_THREAD = 4;
8080

8181
struct tile_extent
8282
{

src/gen/tracer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class tracer_t
3939
std::size_t num_points() const noexcept { return m_num_points; }
4040

4141
private:
42-
static constexpr auto const BITS_PER_WORD = sizeof(potrace_word) * 8;
42+
static constexpr std::size_t BITS_PER_WORD = sizeof(potrace_word) * 8;
4343

4444
geom::point_t make_point(potrace_dpoint_t const &p) const noexcept;
4545

src/geom-area-assembler.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace geom {
1515

16-
const osmium::area::AssemblerConfig area_config;
16+
osmium::area::AssemblerConfig const area_config;
1717

1818
area_assembler_t::area_assembler_t(osmium::memory::Buffer *buffer)
1919
: osmium::area::detail::BasicAssembler(area_config), m_buffer(buffer)
@@ -36,7 +36,7 @@ bool area_assembler_t::make_area()
3636
return true;
3737
}
3838

39-
bool area_assembler_t::operator()(const osmium::Way &way)
39+
bool area_assembler_t::operator()(osmium::Way const &way)
4040
{
4141
segment_list().extract_segments_from_way(nullptr, stats().duplicate_nodes,
4242
way);
@@ -46,10 +46,10 @@ bool area_assembler_t::operator()(const osmium::Way &way)
4646
// Currently the relation is not needed for assembling the area, because
4747
// the roles on the members are ignored. In the future we might want to use
4848
// the roles, so we leave the function signature as it is.
49-
bool area_assembler_t::operator()(const osmium::Relation & /*relation*/,
50-
const osmium::memory::Buffer &ways_buffer)
49+
bool area_assembler_t::operator()(osmium::Relation const & /*relation*/,
50+
osmium::memory::Buffer const &ways_buffer)
5151
{
52-
for (const auto &way : ways_buffer.select<osmium::Way>()) {
52+
for (auto const &way : ways_buffer.select<osmium::Way>()) {
5353
segment_list().extract_segments_from_way(nullptr,
5454
stats().duplicate_nodes, way);
5555
}

src/geom-area-assembler.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class area_assembler_t : public osmium::area::detail::BasicAssembler
3535
* @returns false if there was some kind of error building the
3636
* area, true otherwise.
3737
*/
38-
bool operator()(const osmium::Way &way);
38+
bool operator()(osmium::Way const &way);
3939

4040
/**
4141
* Assemble an area from the given relation and its member ways
@@ -44,8 +44,8 @@ class area_assembler_t : public osmium::area::detail::BasicAssembler
4444
* @returns false if there was some kind of error building the
4545
* area, true otherwise.
4646
*/
47-
bool operator()(const osmium::Relation &relation,
48-
const osmium::memory::Buffer &ways_buffer);
47+
bool operator()(osmium::Relation const &relation,
48+
osmium::memory::Buffer const &ways_buffer);
4949

5050
/**
5151
* Access the area that was built last.

src/geom-from-osm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void create_polygon(geometry_t *geom, osmium::Way const &way,
110110
}
111111

112112
auto const &area = assembler.get_area();
113-
auto const &ring = *area.begin<osmium::OuterRing>();
113+
auto const &ring = *area.cbegin<osmium::OuterRing>();
114114

115115
fill_point_list(&polygon.outer(), ring);
116116
}
@@ -169,7 +169,7 @@ void create_multilinestring(geometry_t *geom,
169169
auto ways = buffer.select<osmium::Way>();
170170
if (ways.size() == 1 && !force_multi) {
171171
auto &line = geom->set<linestring_t>();
172-
auto const &way = *ways.begin();
172+
auto const &way = *ways.cbegin();
173173
if (!fill_point_list(&line, way.nodes())) {
174174
geom->reset();
175175
}
@@ -228,7 +228,7 @@ void create_multipolygon(geometry_t *geom, osmium::Relation const &relation,
228228
}
229229
} else {
230230
auto &polygon = geom->set<polygon_t>();
231-
fill_polygon(&polygon, area, *area.outer_rings().begin());
231+
fill_polygon(&polygon, area, *area.outer_rings().cbegin());
232232
}
233233
}
234234

src/geom-functions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ class without_first
258258

259259
point_list_t::const_iterator begin()
260260
{
261-
assert(m_list->begin() != m_list->end());
262-
return std::next(m_list->begin());
261+
assert(m_list->cbegin() != m_list->cend());
262+
return std::next(m_list->cbegin());
263263
}
264264

265265
point_list_t::const_iterator end() { return m_list->end(); }
@@ -607,7 +607,7 @@ void line_merge(geometry_t *output, geometry_t const &input)
607607
std::vector<endpoint_t> endpoints;
608608

609609
// ...and a list of connections.
610-
constexpr auto const NOCONN = std::numeric_limits<std::size_t>::max();
610+
constexpr std::size_t NOCONN = std::numeric_limits<std::size_t>::max();
611611

612612
struct connection_t
613613
{

src/geom-pole-of-inaccessibility.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ auto point_to_polygon_distance(point_t point, polygon_t const &polygon,
118118

119119
struct Cell
120120
{
121-
static constexpr double const SQRT2 = 1.4142135623730951;
121+
static constexpr double SQRT2 = 1.4142135623730951;
122122

123123
Cell(point_t c, double h, polygon_t const &polygon, double stretch)
124124
: center(c), half_size(h),
@@ -147,7 +147,7 @@ Cell make_centroid_cell(polygon_t const &polygon, double stretch)
147147

148148
} // anonymous namespace
149149

150-
point_t pole_of_inaccessibility(const polygon_t &polygon, double precision,
150+
point_t pole_of_inaccessibility(polygon_t const &polygon, double precision,
151151
double stretch)
152152
{
153153
assert(stretch > 0);
@@ -225,8 +225,8 @@ point_t pole_of_inaccessibility(const polygon_t &polygon, double precision,
225225
auto const h = cell.half_size / 2.0;
226226
auto const center = cell.center;
227227

228-
for (auto dy : {-h, h}) {
229-
for (auto dx : {-h, h}) {
228+
for (auto const dy : {-h, h}) {
229+
for (auto const dx : {-h, h}) {
230230
Cell const c{point_t{center.x() + dx, center.y() + dy}, h,
231231
polygon, stretch};
232232
if (c.max > best_cell.dist) {

src/geom-pole-of-inaccessibility.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace geom {
2828
*
2929
* \pre \code stretch > 0 \endcode
3030
*/
31-
point_t pole_of_inaccessibility(const polygon_t &polygon, double precision,
31+
point_t pole_of_inaccessibility(polygon_t const &polygon, double precision,
3232
double stretch = 1.0);
3333

3434
void pole_of_inaccessibility(geometry_t *output, geometry_t const &input,

0 commit comments

Comments
 (0)