Skip to content

Commit b6bc1c3

Browse files
authored
Merge pull request #2045 from joto/small-cleanups
Various small code cleanups
2 parents 32b9aad + d83d1e1 commit b6bc1c3

File tree

5 files changed

+33
-29
lines changed

5 files changed

+33
-29
lines changed

src/output-pgsql.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,12 @@ void output_pgsql_t::delete_from_output_and_expire(osmid_t id)
352352

353353
for (auto table : {t_line, t_poly}) {
354354
if (m_expire.enabled()) {
355-
auto const results = m_tables[table]->get_wkb(id);
355+
auto const results = m_tables.at(table)->get_wkb(id);
356356
if (expire_from_result(&m_expire, results, m_expire_config) != 0) {
357-
m_tables[table]->delete_row(id);
357+
m_tables.at(table)->delete_row(id);
358358
}
359359
} else {
360-
m_tables[table]->delete_row(id);
360+
m_tables.at(table)->delete_row(id);
361361
}
362362
}
363363
}
@@ -485,7 +485,7 @@ output_pgsql_t::output_pgsql_t(std::shared_ptr<middle_query_t> const &mid,
485485
std::abort(); // should never be here
486486
}
487487

488-
m_tables[i] = std::make_unique<table_t>(
488+
m_tables.at(i) = std::make_unique<table_t>(
489489
name, type, columns, options.hstore_columns,
490490
options.projection->target_srs(), options.append,
491491
options.hstore_mode, copy_thread, options.output_dbschema);
@@ -504,8 +504,8 @@ output_pgsql_t::output_pgsql_t(
504504
{
505505
for (std::size_t i = 0; i < m_tables.size(); ++i) {
506506
//copy constructor will just connect to the already there table
507-
m_tables[i] =
508-
std::make_unique<table_t>(*(other->m_tables[i]), copy_thread);
507+
m_tables.at(i) =
508+
std::make_unique<table_t>(*(other->m_tables.at(i)), copy_thread);
509509
}
510510
}
511511

src/table.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ class table_t
5555

5656
pg_result_t get_wkb(osmid_t id);
5757

58-
task_result_t m_task_result;
59-
6058
private:
6159
void connect();
6260
void prepare();
@@ -81,6 +79,7 @@ class table_t
8179
columns_t m_columns;
8280
hstores_t m_hstore_columns;
8381
std::string m_table_space;
82+
task_result_t m_task_result;
8483

8584
db_copy_mgr_t<db_deleter_by_id_t> m_copy;
8685
};

src/tagtransform-c.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* For a full list of authors see the git log.
88
*/
99

10+
#include <array>
1011
#include <cstdlib>
1112
#include <cstring>
1213

@@ -18,27 +19,30 @@
1819

1920
namespace {
2021

21-
const struct
22+
struct layers_type
2223
{
2324
char const *highway;
2425
int offset;
2526
bool roads;
26-
} layers[] = {{"proposed", 1, false}, {"construction", 2, false},
27-
{"steps", 10, false}, {"cycleway", 10, false},
28-
{"bridleway", 10, false}, {"footway", 10, false},
29-
{"path", 10, false}, {"track", 11, false},
30-
{"service", 15, false},
31-
32-
{"tertiary_link", 24, false}, {"secondary_link", 25, true},
33-
{"primary_link", 27, true}, {"trunk_link", 28, true},
34-
{"motorway_link", 29, true},
35-
36-
{"raceway", 30, false}, {"pedestrian", 31, false},
37-
{"living_street", 32, false}, {"road", 33, false},
38-
{"unclassified", 33, false}, {"residential", 33, false},
39-
{"tertiary", 34, false}, {"secondary", 36, true},
40-
{"primary", 37, true}, {"trunk", 38, true},
41-
{"motorway", 39, true}};
27+
};
28+
29+
constexpr std::array<layers_type, 25> const layers = {
30+
{{"proposed", 1, false}, {"construction", 2, false},
31+
{"steps", 10, false}, {"cycleway", 10, false},
32+
{"bridleway", 10, false}, {"footway", 10, false},
33+
{"path", 10, false}, {"track", 11, false},
34+
{"service", 15, false},
35+
36+
{"tertiary_link", 24, false}, {"secondary_link", 25, true},
37+
{"primary_link", 27, true}, {"trunk_link", 28, true},
38+
{"motorway_link", 29, true},
39+
40+
{"raceway", 30, false}, {"pedestrian", 31, false},
41+
{"living_street", 32, false}, {"road", 33, false},
42+
{"unclassified", 33, false}, {"residential", 33, false},
43+
{"tertiary", 34, false}, {"secondary", 36, true},
44+
{"primary", 37, true}, {"trunk", 38, true},
45+
{"motorway", 39, true}}};
4246

4347
} // anonymous namespace
4448

tests/common-import.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class data_t
7070
data_t() = default;
7171

7272
template <typename CONTAINER>
73-
data_t(CONTAINER const &objects)
73+
explicit data_t(CONTAINER const &objects)
7474
{
7575
std::copy(std::begin(objects), std::end(objects),
7676
std::back_inserter(m_objects));
@@ -167,7 +167,8 @@ class import_t
167167
void run_import(options_t options, char const *data,
168168
std::string const &format = "opl")
169169
{
170-
run_import(options, std::initializer_list<std::string>{data}, format);
170+
run_import(std::move(options), std::initializer_list<std::string>{data},
171+
format);
171172
}
172173

173174
void run_file(options_t options, char const *file = nullptr)
@@ -195,7 +196,7 @@ class import_t
195196

196197
testing::pg::conn_t connect() { return m_db.connect(); }
197198

198-
testing::pg::tempdb_t const &db() const { return m_db; }
199+
testing::pg::tempdb_t const &db() const noexcept { return m_db; }
199200

200201
private:
201202
testing::pg::tempdb_t m_db;

tests/test-output-pgsql-z_order.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ TEST_CASE("compute Z order")
3333
" ORDER BY z_order DESC"
3434
" LIMIT 1 OFFSET {}",
3535
i);
36-
REQUIRE(expected[i] == conn.result_as_string(sql));
36+
REQUIRE(expected.at(i) == conn.result_as_string(sql));
3737
}
3838

3939
REQUIRE("residential" ==

0 commit comments

Comments
 (0)