From acbdfcf3dd9e99247e1a0d5aa269114da23e8539 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Sat, 5 Jul 2025 14:54:38 +0200 Subject: [PATCH 1/4] Use cbegin()/cend() instead of begin()/end() to signal const use --- src/expire-tiles.cpp | 6 +++--- src/geom-from-osm.cpp | 6 +++--- src/geom-functions.cpp | 4 ++-- src/hex.cpp | 2 +- src/output-flex.cpp | 2 +- tests/common-import.hpp | 6 +++--- tests/test-expire-tiles.cpp | 22 +++++++++++----------- tests/test-middle.cpp | 19 ++++++++++--------- tests/test-options-parse.cpp | 4 ++-- 9 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/expire-tiles.cpp b/src/expire-tiles.cpp index d2325f9a1..1cd584f25 100644 --- a/src/expire-tiles.cpp +++ b/src/expire-tiles.cpp @@ -270,7 +270,7 @@ quadkey_list_t expire_tiles::get_tiles() { quadkey_list_t tiles; tiles.reserve(m_dirty_tiles.size()); - tiles.assign(m_dirty_tiles.begin(), m_dirty_tiles.end()); + tiles.assign(m_dirty_tiles.cbegin(), m_dirty_tiles.cend()); std::sort(tiles.begin(), tiles.end()); m_dirty_tiles.clear(); return tiles; @@ -288,8 +288,8 @@ void expire_tiles::merge_and_destroy(expire_tiles *other) using std::swap; swap(m_dirty_tiles, other->m_dirty_tiles); } else { - m_dirty_tiles.insert(other->m_dirty_tiles.begin(), - other->m_dirty_tiles.end()); + m_dirty_tiles.insert(other->m_dirty_tiles.cbegin(), + other->m_dirty_tiles.cend()); other->m_dirty_tiles.clear(); } } diff --git a/src/geom-from-osm.cpp b/src/geom-from-osm.cpp index 71c586519..c1f0f10d8 100644 --- a/src/geom-from-osm.cpp +++ b/src/geom-from-osm.cpp @@ -110,7 +110,7 @@ void create_polygon(geometry_t *geom, osmium::Way const &way, } auto const &area = assembler.get_area(); - auto const &ring = *area.begin(); + auto const &ring = *area.cbegin(); fill_point_list(&polygon.outer(), ring); } @@ -169,7 +169,7 @@ void create_multilinestring(geometry_t *geom, auto ways = buffer.select(); if (ways.size() == 1 && !force_multi) { auto &line = geom->set(); - auto const &way = *ways.begin(); + auto const &way = *ways.cbegin(); if (!fill_point_list(&line, way.nodes())) { geom->reset(); } @@ -228,7 +228,7 @@ void create_multipolygon(geometry_t *geom, osmium::Relation const &relation, } } else { auto &polygon = geom->set(); - fill_polygon(&polygon, area, *area.outer_rings().begin()); + fill_polygon(&polygon, area, *area.outer_rings().cbegin()); } } diff --git a/src/geom-functions.cpp b/src/geom-functions.cpp index 369f9f32c..95c64efee 100644 --- a/src/geom-functions.cpp +++ b/src/geom-functions.cpp @@ -258,8 +258,8 @@ class without_first point_list_t::const_iterator begin() { - assert(m_list->begin() != m_list->end()); - return std::next(m_list->begin()); + assert(m_list->cbegin() != m_list->cend()); + return std::next(m_list->cbegin()); } point_list_t::const_iterator end() { return m_list->end(); } diff --git a/src/hex.cpp b/src/hex.cpp index aec5bca2b..09868f6cd 100644 --- a/src/hex.cpp +++ b/src/hex.cpp @@ -67,7 +67,7 @@ std::string decode_hex(std::string_view hex_string) wkb.reserve(hex_string.size() / 2); // NOLINTNEXTLINE(llvm-qualified-auto, readability-qualified-auto) - for (auto hex = hex_string.begin(); hex != hex_string.end();) { + for (auto hex = hex_string.cbegin(); hex != hex_string.cend();) { unsigned int const c = decode_hex_char(*hex++); wkb += static_cast((c << 4U) | decode_hex_char(*hex++)); } diff --git a/src/output-flex.cpp b/src/output-flex.cpp index 52f65fe47..50d5f0ecf 100644 --- a/src/output-flex.cpp +++ b/src/output-flex.cpp @@ -280,7 +280,7 @@ void flush_tables(std::vector &table_connections) void create_expire_tables(std::vector const &expire_outputs, connection_params_t const &connection_params) { - if (std::all_of(expire_outputs.begin(), expire_outputs.end(), + if (std::all_of(expire_outputs.cbegin(), expire_outputs.cend(), [](auto const &expire_output) { return expire_output.table().empty(); })) { diff --git a/tests/common-import.hpp b/tests/common-import.hpp index 8112cd1d4..532d84a7c 100644 --- a/tests/common-import.hpp +++ b/tests/common-import.hpp @@ -69,7 +69,7 @@ class data_t template explicit data_t(CONTAINER const &objects) { - std::copy(std::begin(objects), std::end(objects), + std::copy(std::cbegin(objects), std::cend(objects), std::back_inserter(m_objects)); } @@ -78,13 +78,13 @@ class data_t template void add(CONTAINER const &objects) { - std::copy(std::begin(objects), std::end(objects), + std::copy(std::cbegin(objects), std::cend(objects), std::back_inserter(m_objects)); } void add(std::initializer_list const &objects) { - std::copy(std::begin(objects), std::end(objects), + std::copy(std::cbegin(objects), std::cend(objects), std::back_inserter(m_objects)); } diff --git a/tests/test-expire-tiles.cpp b/tests/test-expire-tiles.cpp index b1e970283..72717ec87 100644 --- a/tests/test-expire-tiles.cpp +++ b/tests/test-expire-tiles.cpp @@ -100,7 +100,7 @@ TEST_CASE("simple expire z1", "[NoDB]") auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom); CHECK(tiles.size() == 4); - auto itr = tiles.begin(); + auto itr = tiles.cbegin(); CHECK(*(itr++) == tile_t(1, 0, 0)); CHECK(*(itr++) == tile_t(1, 1, 0)); CHECK(*(itr++) == tile_t(1, 0, 1)); @@ -120,7 +120,7 @@ TEST_CASE("simple expire z3", "[NoDB]") auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom); CHECK(tiles.size() == 4); - auto itr = tiles.begin(); + auto itr = tiles.cbegin(); CHECK(*(itr++) == tile_t(3, 3, 3)); CHECK(*(itr++) == tile_t(3, 4, 3)); CHECK(*(itr++) == tile_t(3, 3, 4)); @@ -140,7 +140,7 @@ TEST_CASE("simple expire z18", "[NoDB]") auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom); CHECK(tiles.size() == 4); - auto itr = tiles.begin(); + auto itr = tiles.cbegin(); CHECK(*(itr++) == tile_t(18, 131071, 131071)); CHECK(*(itr++) == tile_t(18, 131072, 131071)); CHECK(*(itr++) == tile_t(18, 131071, 131072)); @@ -159,7 +159,7 @@ TEST_CASE("simple expire z10 bounds 0, 0", "[NoDB]") auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom); CHECK(tiles.size() == 1); - auto itr = tiles.begin(); + auto itr = tiles.cbegin(); CHECK(*(itr++) == tile_t(10, 0, 0)); } @@ -175,7 +175,7 @@ TEST_CASE("simple expire z10 bounds 0, 1023", "[NoDB]") auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom); CHECK(tiles.size() == 1); - auto itr = tiles.begin(); + auto itr = tiles.cbegin(); CHECK(*(itr++) == tile_t(10, 0, 1023)); } @@ -191,7 +191,7 @@ TEST_CASE("simple expire z10 bounds 1023, 0", "[NoDB]") auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom); CHECK(tiles.size() == 1); - auto itr = tiles.begin(); + auto itr = tiles.cbegin(); CHECK(*(itr++) == tile_t(10, 1023, 0)); } @@ -207,7 +207,7 @@ TEST_CASE("simple expire z10 bounds 1023, 1023", "[NoDB]") auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom); CHECK(tiles.size() == 1); - auto itr = tiles.begin(); + auto itr = tiles.cbegin(); CHECK(*(itr++) == tile_t(10, 1023, 1023)); } @@ -223,7 +223,7 @@ TEST_CASE("expire a simple line", "[NoDB]") auto const tiles = get_tiles_ordered(&et, zoom, zoom); CHECK(tiles.size() == 3); - auto itr = tiles.begin(); + auto itr = tiles.cbegin(); CHECK(*(itr++) == tile_t(18, 140221, 82055)); CHECK(*(itr++) == tile_t(18, 140222, 82055)); CHECK(*(itr++) == tile_t(18, 140223, 82055)); @@ -241,7 +241,7 @@ TEST_CASE("expire a line near the tile border", "[NoDB]") auto const tiles = get_tiles_ordered(&et, zoom, zoom); REQUIRE(tiles.size() == 4); - auto itr = tiles.begin(); + auto itr = tiles.cbegin(); CHECK(*(itr++) == tile_t(18, 140222, 82055)); CHECK(*(itr++) == tile_t(18, 140223, 82055)); CHECK(*(itr++) == tile_t(18, 140222, 82056)); @@ -331,7 +331,7 @@ TEST_CASE("simple expire z17 and z18", "[NoDB]") auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom); CHECK(tiles.size() == 8); - auto itr = tiles.begin(); + auto itr = tiles.cbegin(); CHECK(*(itr++) == tile_t(18, 131071, 131071)); CHECK(*(itr++) == tile_t(17, 65535, 65535)); CHECK(*(itr++) == tile_t(18, 131072, 131071)); @@ -356,7 +356,7 @@ TEST_CASE("simple expire z17 and z18 in one superior tile", "[NoDB]") auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom); CHECK(tiles.size() == 5); - auto itr = tiles.begin(); + auto itr = tiles.cbegin(); CHECK(*(itr++) == tile_t(18, 131070, 131070)); CHECK(*(itr++) == tile_t(17, 65535, 65535)); CHECK(*(itr++) == tile_t(18, 131071, 131070)); diff --git a/tests/test-middle.cpp b/tests/test-middle.cpp index 51d3ea453..5c52a4e84 100644 --- a/tests/test-middle.cpp +++ b/tests/test-middle.cpp @@ -517,14 +517,14 @@ void check_way(std::shared_ptr const &mid, CHECK(std::strcmp(orig_way.user(), way.user()) == 0); REQUIRE(orig_way.tags().size() == way.tags().size()); - for (auto it1 = orig_way.tags().begin(), it2 = way.tags().begin(); - it1 != orig_way.tags().end(); ++it1, ++it2) { + for (auto it1 = orig_way.tags().cbegin(), it2 = way.tags().cbegin(); + it1 != orig_way.tags().cend(); ++it1, ++it2) { CHECK(*it1 == *it2); } REQUIRE(orig_way.nodes().size() == way.nodes().size()); - for (auto it1 = orig_way.nodes().begin(), it2 = way.nodes().begin(); - it1 != orig_way.nodes().end(); ++it1, ++it2) { + for (auto it1 = orig_way.nodes().cbegin(), it2 = way.nodes().cbegin(); + it1 != orig_way.nodes().cend(); ++it1, ++it2) { CHECK(*it1 == *it2); } @@ -792,15 +792,16 @@ void check_relation(std::shared_ptr const &mid, CHECK(std::strcmp(orig_relation.user(), relation.user()) == 0); REQUIRE(orig_relation.tags().size() == relation.tags().size()); - for (auto it1 = orig_relation.tags().begin(), it2 = relation.tags().begin(); - it1 != orig_relation.tags().end(); ++it1, ++it2) { + for (auto it1 = orig_relation.tags().cbegin(), + it2 = relation.tags().cbegin(); + it1 != orig_relation.tags().cend(); ++it1, ++it2) { CHECK(*it1 == *it2); } REQUIRE(orig_relation.members().size() == relation.members().size()); - for (auto it1 = orig_relation.members().begin(), - it2 = relation.members().begin(); - it1 != orig_relation.members().end(); ++it1, ++it2) { + for (auto it1 = orig_relation.members().cbegin(), + it2 = relation.members().cbegin(); + it1 != orig_relation.members().cend(); ++it1, ++it2) { CHECK(it1->type() == it2->type()); CHECK(it1->ref() == it2->ref()); CHECK(std::strcmp(it1->role(), it2->role()) == 0); diff --git a/tests/test-options-parse.cpp b/tests/test-options-parse.cpp index 641fbb283..b2ca41f41 100644 --- a/tests/test-options-parse.cpp +++ b/tests/test-options-parse.cpp @@ -21,7 +21,7 @@ char const *const TEST_PBF = "foo.pbf"; void bad_opt(std::vector opts, char const *msg) { - opts.insert(opts.begin(), "osm2pgsql"); + opts.insert(opts.cbegin(), "osm2pgsql"); opts.push_back(TEST_PBF); REQUIRE_THROWS_WITH( @@ -31,7 +31,7 @@ void bad_opt(std::vector opts, char const *msg) options_t opt(std::vector opts) { - opts.insert(opts.begin(), "osm2pgsql"); + opts.insert(opts.cbegin(), "osm2pgsql"); opts.push_back(TEST_PBF); return parse_command_line((int)opts.size(), (char **)opts.data()); From c3cd871db5240c1a6d4510eb4f715ab11dea9990 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Sat, 5 Jul 2025 15:21:54 +0200 Subject: [PATCH 2/4] Use const (ref) variables for loops where possible --- src/db-copy.cpp | 2 +- src/geom-pole-of-inaccessibility.cpp | 4 ++-- src/middle-pgsql.cpp | 2 +- src/output-flex.cpp | 2 +- src/output-pgsql.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/db-copy.cpp b/src/db-copy.cpp index be2eee2e0..300be9bd2 100644 --- a/src/db-copy.cpp +++ b/src/db-copy.cpp @@ -31,7 +31,7 @@ void db_deleter_by_id_t::delete_rows(std::string const &table, fmt::format_to(std::back_inserter(sql), FMT_STRING("DELETE FROM {} WHERE {} IN ("), table, column); - for (auto id : m_deletables) { + for (auto const id : m_deletables) { format_to(std::back_inserter(sql), FMT_STRING("{},"), id); } sql[sql.size() - 1] = ')'; diff --git a/src/geom-pole-of-inaccessibility.cpp b/src/geom-pole-of-inaccessibility.cpp index 1573828f5..3e11d1810 100644 --- a/src/geom-pole-of-inaccessibility.cpp +++ b/src/geom-pole-of-inaccessibility.cpp @@ -225,8 +225,8 @@ point_t pole_of_inaccessibility(const polygon_t &polygon, double precision, auto const h = cell.half_size / 2.0; auto const center = cell.center; - for (auto dy : {-h, h}) { - for (auto dx : {-h, h}) { + for (auto const dy : {-h, h}) { + for (auto const dx : {-h, h}) { Cell const c{point_t{center.x() + dx, center.y() + dy}, h, polygon, stretch}; if (c.max > best_cell.dist) { diff --git a/src/middle-pgsql.cpp b/src/middle-pgsql.cpp index a52aad1a4..77e3695de 100644 --- a/src/middle-pgsql.cpp +++ b/src/middle-pgsql.cpp @@ -1168,7 +1168,7 @@ void middle_pgsql_t::stop() if (m_options->droptemp) { // Dropping the tables is fast, so do it synchronously to guarantee // that the space is freed before creating the other indices. - for (auto &table : m_tables) { + for (auto const &table : m_tables) { table.drop_table(m_db_connection); } } else if (!m_options->append) { diff --git a/src/output-flex.cpp b/src/output-flex.cpp index 50d5f0ecf..67413d278 100644 --- a/src/output-flex.cpp +++ b/src/output-flex.cpp @@ -1258,7 +1258,7 @@ output_flex_t::output_flex_t(std::shared_ptr const &mid, m_table_connections.emplace_back(&table, m_copy_thread); } - for (auto &expire_output : *m_expire_outputs) { + for (auto const &expire_output : *m_expire_outputs) { m_expire_tiles.emplace_back( expire_output.maxzoom(), reprojection::create_projection(PROJ_SPHERE_MERC)); diff --git a/src/output-pgsql.cpp b/src/output-pgsql.cpp index 8167645d4..e0756bff0 100644 --- a/src/output-pgsql.cpp +++ b/src/output-pgsql.cpp @@ -366,7 +366,7 @@ void output_pgsql_t::delete_from_output_and_expire(osmid_t id) { m_tables[t_roads]->delete_row(id); - for (auto table : {t_line, t_poly}) { + for (auto const table : {t_line, t_poly}) { if (m_expire.enabled()) { auto const results = m_tables.at(table)->get_wkb(id); if (expire_from_result(&m_expire, results, m_expire_config) != 0) { From cec20ae09bbcfc4420f209cd0fc6e828d9a34a03 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Sat, 5 Jul 2025 15:32:08 +0200 Subject: [PATCH 3/4] Use east const consistently --- src/geom-area-assembler.cpp | 10 +++++----- src/geom-area-assembler.hpp | 6 +++--- src/geom-pole-of-inaccessibility.cpp | 2 +- src/geom-pole-of-inaccessibility.hpp | 2 +- src/idlist.cpp | 2 +- src/middle-pgsql.cpp | 10 +++++----- src/osm2pgsql.cpp | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/geom-area-assembler.cpp b/src/geom-area-assembler.cpp index 99e9633ff..332bd83c3 100644 --- a/src/geom-area-assembler.cpp +++ b/src/geom-area-assembler.cpp @@ -13,7 +13,7 @@ namespace geom { -const osmium::area::AssemblerConfig area_config; +osmium::area::AssemblerConfig const area_config; area_assembler_t::area_assembler_t(osmium::memory::Buffer *buffer) : osmium::area::detail::BasicAssembler(area_config), m_buffer(buffer) @@ -36,7 +36,7 @@ bool area_assembler_t::make_area() return true; } -bool area_assembler_t::operator()(const osmium::Way &way) +bool area_assembler_t::operator()(osmium::Way const &way) { segment_list().extract_segments_from_way(nullptr, stats().duplicate_nodes, way); @@ -46,10 +46,10 @@ bool area_assembler_t::operator()(const osmium::Way &way) // Currently the relation is not needed for assembling the area, because // the roles on the members are ignored. In the future we might want to use // the roles, so we leave the function signature as it is. -bool area_assembler_t::operator()(const osmium::Relation & /*relation*/, - const osmium::memory::Buffer &ways_buffer) +bool area_assembler_t::operator()(osmium::Relation const & /*relation*/, + osmium::memory::Buffer const &ways_buffer) { - for (const auto &way : ways_buffer.select()) { + for (auto const &way : ways_buffer.select()) { segment_list().extract_segments_from_way(nullptr, stats().duplicate_nodes, way); } diff --git a/src/geom-area-assembler.hpp b/src/geom-area-assembler.hpp index e00f95f26..a83c27ee6 100644 --- a/src/geom-area-assembler.hpp +++ b/src/geom-area-assembler.hpp @@ -35,7 +35,7 @@ class area_assembler_t : public osmium::area::detail::BasicAssembler * @returns false if there was some kind of error building the * area, true otherwise. */ - bool operator()(const osmium::Way &way); + bool operator()(osmium::Way const &way); /** * Assemble an area from the given relation and its member ways @@ -44,8 +44,8 @@ class area_assembler_t : public osmium::area::detail::BasicAssembler * @returns false if there was some kind of error building the * area, true otherwise. */ - bool operator()(const osmium::Relation &relation, - const osmium::memory::Buffer &ways_buffer); + bool operator()(osmium::Relation const &relation, + osmium::memory::Buffer const &ways_buffer); /** * Access the area that was built last. diff --git a/src/geom-pole-of-inaccessibility.cpp b/src/geom-pole-of-inaccessibility.cpp index 3e11d1810..72c578a0d 100644 --- a/src/geom-pole-of-inaccessibility.cpp +++ b/src/geom-pole-of-inaccessibility.cpp @@ -147,7 +147,7 @@ Cell make_centroid_cell(polygon_t const &polygon, double stretch) } // anonymous namespace -point_t pole_of_inaccessibility(const polygon_t &polygon, double precision, +point_t pole_of_inaccessibility(polygon_t const &polygon, double precision, double stretch) { assert(stretch > 0); diff --git a/src/geom-pole-of-inaccessibility.hpp b/src/geom-pole-of-inaccessibility.hpp index d4a2d5a76..6b9c46b2f 100644 --- a/src/geom-pole-of-inaccessibility.hpp +++ b/src/geom-pole-of-inaccessibility.hpp @@ -28,7 +28,7 @@ namespace geom { * * \pre \code stretch > 0 \endcode */ -point_t pole_of_inaccessibility(const polygon_t &polygon, double precision, +point_t pole_of_inaccessibility(polygon_t const &polygon, double precision, double stretch = 1.0); void pole_of_inaccessibility(geometry_t *output, geometry_t const &input, diff --git a/src/idlist.cpp b/src/idlist.cpp index 44dc7cd7d..3a2581ae5 100644 --- a/src/idlist.cpp +++ b/src/idlist.cpp @@ -25,7 +25,7 @@ osmid_t idlist_t::pop_id() void idlist_t::sort_unique() { std::sort(m_list.begin(), m_list.end()); - const auto last = std::unique(m_list.begin(), m_list.end()); + auto const last = std::unique(m_list.begin(), m_list.end()); m_list.erase(last, m_list.end()); } diff --git a/src/middle-pgsql.cpp b/src/middle-pgsql.cpp index 77e3695de..7d6aae5ee 100644 --- a/src/middle-pgsql.cpp +++ b/src/middle-pgsql.cpp @@ -47,8 +47,8 @@ namespace { -void send_id_list(pg_conn_t const &db_connection, - std::string const &table, idlist_t const &ids) +void send_id_list(pg_conn_t const &db_connection, std::string const &table, + idlist_t const &ids) { std::string data; for (auto const id : ids) { @@ -171,7 +171,7 @@ class member_list_json_builder } static bool number_float(nlohmann::json::number_float_t /*val*/, - const nlohmann::json::string_t & /*s*/) + nlohmann::json::string_t const & /*s*/) { return true; } @@ -228,8 +228,8 @@ class member_list_json_builder static bool end_array() { return true; } static bool parse_error(std::size_t /*position*/, - const std::string & /*last_token*/, - const nlohmann::json::exception &ex) + std::string const & /*last_token*/, + nlohmann::json::exception const &ex) { throw ex; } diff --git a/src/osm2pgsql.cpp b/src/osm2pgsql.cpp index f07a6b413..10960162e 100644 --- a/src/osm2pgsql.cpp +++ b/src/osm2pgsql.cpp @@ -188,7 +188,7 @@ void check_and_update_flat_node_file(properties_t *properties, flat_node_file_from_import); } } else { - const auto absolute_path = + auto const absolute_path = std::filesystem::absolute( std::filesystem::path{options->flat_node_file}) .string(); @@ -279,7 +279,7 @@ void check_and_update_style_file(properties_t *properties, options_t *options) throw std::runtime_error{"Style file from import is empty!?"}; } - const auto absolute_path = + auto const absolute_path = std::filesystem::absolute(std::filesystem::path{options->style}) .string(); From fec8513aa4380a6c752d9d8b7bdaf903438aedf6 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Sat, 5 Jul 2025 15:37:48 +0200 Subject: [PATCH 4/4] constexpr const is redundant --- src/gen/osm2pgsql-gen.cpp | 2 +- src/gen/tracer.hpp | 2 +- src/geom-functions.cpp | 2 +- src/geom-pole-of-inaccessibility.cpp | 2 +- src/geom.hpp | 2 +- src/hex.cpp | 2 +- src/node-locations.cpp | 2 +- src/node-locations.hpp | 2 +- src/ordered-index.hpp | 2 +- src/output-flex.cpp | 4 ++-- src/pgsql.hpp | 2 +- src/tagtransform-c.cpp | 2 +- src/thread-pool.hpp | 2 +- src/tile.hpp | 9 ++++----- src/wkb.cpp | 2 +- tests/test-expire-from-geometry.cpp | 2 +- tests/test-ordered-index.cpp | 8 ++++---- tests/test-output-flex-nodes.cpp | 2 +- 18 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/gen/osm2pgsql-gen.cpp b/src/gen/osm2pgsql-gen.cpp index 84b1a5830..0be98a874 100644 --- a/src/gen/osm2pgsql-gen.cpp +++ b/src/gen/osm2pgsql-gen.cpp @@ -76,7 +76,7 @@ namespace { -constexpr std::size_t const MAX_FORCE_SINGLE_THREAD = 4; +constexpr std::size_t MAX_FORCE_SINGLE_THREAD = 4; struct tile_extent { diff --git a/src/gen/tracer.hpp b/src/gen/tracer.hpp index d22d49646..1171f1d5a 100644 --- a/src/gen/tracer.hpp +++ b/src/gen/tracer.hpp @@ -39,7 +39,7 @@ class tracer_t std::size_t num_points() const noexcept { return m_num_points; } private: - static constexpr auto const BITS_PER_WORD = sizeof(potrace_word) * 8; + static constexpr std::size_t BITS_PER_WORD = sizeof(potrace_word) * 8; geom::point_t make_point(potrace_dpoint_t const &p) const noexcept; diff --git a/src/geom-functions.cpp b/src/geom-functions.cpp index 95c64efee..4d53c3d43 100644 --- a/src/geom-functions.cpp +++ b/src/geom-functions.cpp @@ -607,7 +607,7 @@ void line_merge(geometry_t *output, geometry_t const &input) std::vector endpoints; // ...and a list of connections. - constexpr auto const NOCONN = std::numeric_limits::max(); + constexpr std::size_t NOCONN = std::numeric_limits::max(); struct connection_t { diff --git a/src/geom-pole-of-inaccessibility.cpp b/src/geom-pole-of-inaccessibility.cpp index 72c578a0d..daa6e2173 100644 --- a/src/geom-pole-of-inaccessibility.cpp +++ b/src/geom-pole-of-inaccessibility.cpp @@ -118,7 +118,7 @@ auto point_to_polygon_distance(point_t point, polygon_t const &polygon, struct Cell { - static constexpr double const SQRT2 = 1.4142135623730951; + static constexpr double SQRT2 = 1.4142135623730951; Cell(point_t c, double h, polygon_t const &polygon, double stretch) : center(c), half_size(h), diff --git a/src/geom.hpp b/src/geom.hpp index ac71c7653..24915524d 100644 --- a/src/geom.hpp +++ b/src/geom.hpp @@ -200,7 +200,7 @@ class multigeometry_t using iterator = typename std::vector::iterator; using value_type = GEOM; - static constexpr bool const FOR_POINT = std::is_same_v; + static constexpr bool FOR_POINT = std::is_same_v; [[nodiscard]] std::size_t num_geometries() const noexcept { diff --git a/src/hex.cpp b/src/hex.cpp index 09868f6cd..51cf01cad 100644 --- a/src/hex.cpp +++ b/src/hex.cpp @@ -38,7 +38,7 @@ std::string encode_hex(std::string const &in) namespace { -constexpr std::array const HEX_TABLE = { +constexpr std::array HEX_TABLE = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/node-locations.cpp b/src/node-locations.cpp index 9f1a2eac8..1ce3787b2 100644 --- a/src/node-locations.cpp +++ b/src/node-locations.cpp @@ -83,7 +83,7 @@ osmium::Location node_locations_t::get(osmid_t id) const void node_locations_t::log_stats() { - constexpr auto const MBYTE = 1024 * 1024; + constexpr auto MBYTE = 1024 * 1024; log_debug("Node locations cache:"); log_debug(" num locations stored: {}", m_count); log_debug(" bytes overall: {}MB", used_memory() / MBYTE); diff --git a/src/node-locations.hpp b/src/node-locations.hpp index cf50b68a0..d520d03d5 100644 --- a/src/node-locations.hpp +++ b/src/node-locations.hpp @@ -85,7 +85,7 @@ class node_locations_t * The block size used for internal blocks. The larger the block size * the less memory is consumed but the more expensive the access is. */ - static constexpr const std::size_t BLOCK_SIZE = 32; + static constexpr std::size_t BLOCK_SIZE = 32; bool first_entry_in_block() const noexcept { diff --git a/src/ordered-index.hpp b/src/ordered-index.hpp index 70790f014..f8792b975 100644 --- a/src/ordered-index.hpp +++ b/src/ordered-index.hpp @@ -185,7 +185,7 @@ class ordered_index_t std::pair get_internal(osmid_t id) const noexcept; - static constexpr std::size_t const MAX_BLOCK_SIZE = 16UL * 1024UL * 1024UL; + static constexpr std::size_t MAX_BLOCK_SIZE = 16UL * 1024UL * 1024UL; std::vector m_ranges; std::size_t m_block_size; diff --git a/src/output-flex.cpp b/src/output-flex.cpp index 67413d278..3a3b4e625 100644 --- a/src/output-flex.cpp +++ b/src/output-flex.cpp @@ -133,7 +133,7 @@ void push_osm_object_to_lua_stack(lua_State *lua_state, * timestamp, changeset, uid, user). For ways there are 2 more (is_closed, * nodes), for relations 1 more (members). */ - constexpr int const MAX_TABLE_SIZE = 10; + constexpr int MAX_TABLE_SIZE = 10; lua_createtable(lua_state, 0, MAX_TABLE_SIZE); @@ -243,7 +243,7 @@ typename CONTAINER::value_type &get_from_idx_param(lua_State *lua_state, std::size_t get_nodes(middle_query_t const &middle, osmium::Way *way) { - constexpr std::size_t const MAX_MISSING_NODES = 100; + constexpr std::size_t MAX_MISSING_NODES = 100; static std::size_t count_missing_nodes = 0; auto const count = middle.nodes_get_list(&way->nodes()); diff --git a/src/pgsql.hpp b/src/pgsql.hpp index be2d6f9ad..17a28f54e 100644 --- a/src/pgsql.hpp +++ b/src/pgsql.hpp @@ -319,7 +319,7 @@ class pg_conn_t // It needs to be large enough to hold all parameters without resizing // so that pointers into the strings in that vector remain valid // after new parameters have been added. - constexpr auto const TOTAL_BUFFERS_NEEDED = + constexpr auto TOTAL_BUFFERS_NEEDED = (0 + ... + buffers_needed>()); std::vector exec_params; diff --git a/src/tagtransform-c.cpp b/src/tagtransform-c.cpp index 27addf710..c1b87b69c 100644 --- a/src/tagtransform-c.cpp +++ b/src/tagtransform-c.cpp @@ -26,7 +26,7 @@ struct layers_type bool roads; }; -constexpr std::array const LAYERS = { +constexpr std::array LAYERS = { {{"proposed", 1, false}, {"construction", 2, false}, {"steps", 10, false}, {"cycleway", 10, false}, {"bridleway", 10, false}, {"footway", 10, false}, diff --git a/src/thread-pool.hpp b/src/thread-pool.hpp index 11d1afac9..0b66f115e 100644 --- a/src/thread-pool.hpp +++ b/src/thread-pool.hpp @@ -151,7 +151,7 @@ class thread_pool_t }; // class thread_joiner - static constexpr std::size_t const MAX_QUEUE_SIZE = 32; + static constexpr std::size_t MAX_QUEUE_SIZE = 32; osmium::thread::Queue m_work_queue; std::vector m_threads; diff --git a/src/tile.hpp b/src/tile.hpp index c95a376e9..99b248f32 100644 --- a/src/tile.hpp +++ b/src/tile.hpp @@ -73,9 +73,8 @@ using quadkey_list_t = std::vector; class tile_t { public: - static constexpr double const EARTH_CIRCUMFERENCE = 40075016.68; - static constexpr double const HALF_EARTH_CIRCUMFERENCE = - EARTH_CIRCUMFERENCE / 2; + static constexpr double EARTH_CIRCUMFERENCE = 40075016.68; + static constexpr double HALF_EARTH_CIRCUMFERENCE = EARTH_CIRCUMFERENCE / 2; /// Construct an invalid tile. tile_t() noexcept = default; @@ -258,10 +257,10 @@ class tile_t static tile_t from_quadkey(quadkey_t quadkey, uint32_t zoom) noexcept; private: - static constexpr uint32_t const INVALID_ZOOM = + static constexpr uint32_t INVALID_ZOOM = std::numeric_limits::max(); - static constexpr uint32_t const MAX_ZOOM = 32; + static constexpr uint32_t MAX_ZOOM = 32; uint32_t m_x = 0; uint32_t m_y = 0; diff --git a/src/wkb.cpp b/src/wkb.cpp index 07efec0fd..cf25f2d7c 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -217,7 +217,7 @@ class make_ewkb_visitor write_point(&data, geom); } else { // 9 byte header plus one set of coordinates - constexpr const std::size_t SIZE = 9 + 2 * 8; + constexpr std::size_t SIZE = 9 + 2 * 8; data.reserve(SIZE); write_point(&data, geom, m_srid); assert(data.size() == SIZE); diff --git a/tests/test-expire-from-geometry.cpp b/tests/test-expire-from-geometry.cpp index f0c73c47f..0260a7533 100644 --- a/tests/test-expire-from-geometry.cpp +++ b/tests/test-expire-from-geometry.cpp @@ -25,7 +25,7 @@ std::shared_ptr defproj{ // We are using zoom level 12 here, because at that level a tile is about // 10,000 units wide/high which gives us easy numbers to work with. -constexpr uint32_t const zoom = 12; +constexpr uint32_t zoom = 12; } // anonymous namespace diff --git a/tests/test-ordered-index.cpp b/tests/test-ordered-index.cpp index da75d89c6..5a06abc00 100644 --- a/tests/test-ordered-index.cpp +++ b/tests/test-ordered-index.cpp @@ -13,7 +13,7 @@ TEST_CASE("ordered index basics", "[NoDB]") { - constexpr std::size_t const block_size = 16; + constexpr std::size_t block_size = 16; ordered_index_t index{block_size}; REQUIRE(index.size() == 0); @@ -38,7 +38,7 @@ TEST_CASE("ordered index basics", "[NoDB]") TEST_CASE("ordered index set/get", "[NoDB]") { - constexpr std::size_t const block_size = 16; + constexpr std::size_t block_size = 16; ordered_index_t index{block_size}; index.add(19, 0); @@ -64,7 +64,7 @@ TEST_CASE("ordered index set/get", "[NoDB]") TEST_CASE("ordered index set/get with multiple second-level blocks", "[NoDB]") { - constexpr std::size_t const block_size = 4; + constexpr std::size_t block_size = 4; ordered_index_t index{block_size}; index.add(19, 0); @@ -106,7 +106,7 @@ TEST_CASE("ordered index set/get with multiple second-level blocks", "[NoDB]") TEST_CASE("ordered index with huge gaps in ids", "[NoDB]") { - constexpr std::size_t const block_size = 4; + constexpr std::size_t block_size = 4; ordered_index_t index{block_size}; index.add(1, 0); diff --git a/tests/test-output-flex-nodes.cpp b/tests/test-output-flex-nodes.cpp index 3dae49be8..9ffbf85ae 100644 --- a/tests/test-output-flex-nodes.cpp +++ b/tests/test-output-flex-nodes.cpp @@ -63,7 +63,7 @@ enum class node_relationship : std::uint8_t template struct node_rel { - static constexpr const node_relationship rs = R; + static constexpr node_relationship rs = R; }; using node_rel_none = node_rel;