Skip to content

Commit 45aa0b3

Browse files
committed
Add lots of const's to the code
1 parent 3d4bb81 commit 45aa0b3

21 files changed

+55
-52
lines changed

src/db-copy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void db_deleter_by_type_and_id_t::delete_rows(std::string const &table,
6060

6161
auto const pos = column.find(',');
6262
assert(pos != std::string::npos);
63-
std::string type = column.substr(0, pos);
63+
std::string const type = column.substr(0, pos);
6464

6565
fmt::format_to(std::back_inserter(sql),
6666
") AS t (osm_type, osm_id) WHERE"
@@ -106,7 +106,7 @@ void db_copy_thread_t::add_buffer(std::unique_ptr<db_cmd_t> &&buffer)
106106
void db_copy_thread_t::sync_and_wait()
107107
{
108108
std::promise<void> barrier;
109-
std::future<void> sync = barrier.get_future();
109+
std::future<void> const sync = barrier.get_future();
110110
add_buffer(std::make_unique<db_cmd_sync_t>(std::move(barrier)));
111111
sync.wait();
112112
}

src/flex-table-column.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static std::string lowercase(std::string const &str)
6969
{
7070
std::string result;
7171

72-
for (char c : str) {
72+
for (char const c : str) {
7373
result +=
7474
static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
7575
}

src/gazetteer-style.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ void gazetteer_style_t::copy_out(osmium::OSMObject const &o,
480480
buffer->add_column(std::get<1>(tag));
481481
// names
482482
if (std::get<2>(tag) & SF_MAIN_NAMED_KEY) {
483-
DomainMatcher m{std::get<0>(tag)};
483+
DomainMatcher const m{std::get<0>(tag)};
484484
buffer->new_hash();
485485
for (auto const &t : o.tags()) {
486486
char const *const k = m(t);
@@ -562,7 +562,7 @@ void gazetteer_style_t::copy_out(osmium::OSMObject const &o,
562562
"osm_changeset", o.changeset());
563563
}
564564
if (m_metadata_fields.timestamp() && o.timestamp()) {
565-
std::string timestamp = o.timestamp().to_iso();
565+
std::string const timestamp = o.timestamp().to_iso();
566566
buffer->add_hash_elem_noescape("osm_timestamp",
567567
timestamp.c_str());
568568
}

src/input.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ prepare_input_files(std::vector<std::string> const &input_files,
180180
std::vector<osmium::io::File> files;
181181

182182
for (auto const &filename : input_files) {
183-
osmium::io::File file{filename, input_format};
183+
osmium::io::File const file{filename, input_format};
184184

185185
if (file.format() == osmium::io::file_format::unknown) {
186186
if (input_format.empty()) {

src/middle-pgsql.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void middle_pgsql_t::table_desc::build_index(std::string const &conninfo) const
9999

100100
// Use a temporary connection here because we might run in a separate
101101
// thread context.
102-
pg_conn_t db_connection{conninfo};
102+
pg_conn_t const db_connection{conninfo};
103103

104104
log_info("Building index on table '{}'", name());
105105
db_connection.exec(m_create_fw_dep_indexes);
@@ -191,9 +191,9 @@ void pgsql_parse_members(char const *string, osmium::memory::Buffer *buffer,
191191
osmium::builder::RelationMemberListBuilder builder{*buffer, obuilder};
192192

193193
while (*string != '}') {
194-
char type = string[0];
194+
char const type = string[0];
195195
char *endp = nullptr;
196-
osmid_t id = std::strtoll(string + 1, &endp, 10);
196+
osmid_t const id = std::strtoll(string + 1, &endp, 10);
197197
// String points to the comma */
198198
string = decode_to_delimiter(endp + 1, &role);
199199
builder.add_member(osmium::char_to_item_type(type), id, role);

src/osm2pgsql.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*/
3434
static void show_memory_usage()
3535
{
36-
osmium::MemoryUsage mem;
36+
osmium::MemoryUsage const mem;
3737
if (mem.peak() != 0) {
3838
log_debug("Overall memory usage: peak={}MByte current={}MByte",
3939
mem.peak(), mem.current());
@@ -80,7 +80,7 @@ static void run(options_t const &options)
8080

8181
void check_db(options_t const &options)
8282
{
83-
pg_conn_t db_connection{options.conninfo};
83+
pg_conn_t const db_connection{options.conninfo};
8484

8585
init_database_capabilities(db_connection);
8686

src/output-flex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ void output_flex_t::call_lua_function(prepared_lua_function_t func,
11231123
void output_flex_t::get_mutex_and_call_lua_function(
11241124
prepared_lua_function_t func, osmium::OSMObject const &object)
11251125
{
1126-
std::lock_guard<std::mutex> guard{lua_mutex};
1126+
std::lock_guard<std::mutex> const guard{lua_mutex};
11271127
call_lua_function(func, object);
11281128
}
11291129

@@ -1148,7 +1148,7 @@ void output_flex_t::select_relation_members()
11481148
return;
11491149
}
11501150

1151-
std::lock_guard<std::mutex> guard{lua_mutex};
1151+
std::lock_guard<std::mutex> const guard{lua_mutex};
11521152
call_lua_function(m_select_relation_members, m_relation_cache.get());
11531153

11541154
// If the function returned nil there is nothing to be marked.

src/output-gazetteer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void output_gazetteer_t::start()
4949
if (!get_options()->append) {
5050
int const srid = get_options()->projection->target_srs();
5151

52-
pg_conn_t conn{get_options()->conninfo};
52+
pg_conn_t const conn{get_options()->conninfo};
5353

5454
/* Drop any existing table */
5555
conn.exec("DROP TABLE IF EXISTS place CASCADE");

src/output-pgsql.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ output_pgsql_t::output_pgsql_t(std::shared_ptr<middle_query_t> const &mid,
442442
for (std::size_t i = 0; i < m_tables.size(); ++i) {
443443

444444
//figure out the columns this table needs
445-
columns_t columns = exlist.normal_columns(
445+
columns_t const columns = exlist.normal_columns(
446446
(i == t_point) ? osmium::item_type::node : osmium::item_type::way);
447447

448448
//figure out what name we are using for this and what type

src/pgsql-helper.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ void create_geom_check_trigger(pg_conn_t *db_connection,
3737
std::string const &table,
3838
std::string const &condition)
3939
{
40-
std::string func_name = qualified_name(schema, table + "_osm2pgsql_valid");
40+
std::string const func_name =
41+
qualified_name(schema, table + "_osm2pgsql_valid");
4142

4243
db_connection->exec("CREATE OR REPLACE FUNCTION {}()\n"
4344
"RETURNS TRIGGER AS $$\n"
@@ -63,7 +64,8 @@ void drop_geom_check_trigger(pg_conn_t *db_connection,
6364
std::string const &schema,
6465
std::string const &table)
6566
{
66-
std::string func_name = qualified_name(schema, table + "_osm2pgsql_valid");
67+
std::string const func_name =
68+
qualified_name(schema, table + "_osm2pgsql_valid");
6769

6870
db_connection->exec(R"(DROP TRIGGER "{}" ON {})",
6971
table + "_osm2pgsql_valid",

0 commit comments

Comments
 (0)