Skip to content

Commit 51565f4

Browse files
committed
Modernize code: Use pass-by-value and std::move()
1 parent f0e5913 commit 51565f4

12 files changed

+30
-29
lines changed

src/flex-table-column.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ static std::string lowercase(std::string const &str)
8282

8383
flex_table_column_t::flex_table_column_t(std::string name,
8484
std::string const &type,
85-
std::string const &sql_type)
85+
std::string sql_type)
8686
: m_name(std::move(name)), m_type_name(lowercase(type)),
87-
m_sql_type(sql_type),
87+
m_sql_type(std::move(sql_type)),
8888
m_type(get_column_type_from_string(m_type_name))
8989
{}
9090

src/flex-table-column.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class flex_table_column_t
5353
{
5454
public:
5555
flex_table_column_t(std::string name, std::string const &type,
56-
std::string const &sql_type);
56+
std::string sql_type);
5757

5858
std::string const &name() const noexcept { return m_name; }
5959

src/gazetteer-style.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class db_deleter_place_t
4444
osmid_t osm_id;
4545
char osm_type;
4646

47-
item_t(char t, osmid_t i, std::string const &c)
48-
: classes(c), osm_id(i), osm_type(t)
47+
item_t(char t, osmid_t i, std::string c)
48+
: classes(std::move(c)), osm_id(i), osm_type(t)
4949
{}
5050

5151
item_t(char t, osmid_t i) : osm_id(i), osm_type(t) {}

src/middle-pgsql.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,10 @@ void middle_pgsql_t::after_relations()
590590
}
591591

592592
middle_query_pgsql_t::middle_query_pgsql_t(
593-
std::string const &conninfo, std::shared_ptr<node_locations_t> const &cache,
594-
std::shared_ptr<node_persistent_cache> const &persistent_cache)
595-
: m_sql_conn(conninfo), m_cache(cache), m_persistent_cache(persistent_cache)
593+
std::string const &conninfo, std::shared_ptr<node_locations_t> cache,
594+
std::shared_ptr<node_persistent_cache> persistent_cache)
595+
: m_sql_conn(conninfo), m_cache(std::move(cache)),
596+
m_persistent_cache(std::move(persistent_cache))
596597
{
597598
// Disable JIT and parallel workers as they are known to cause
598599
// problems when accessing the intarrays.

src/middle-pgsql.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ class middle_query_pgsql_t : public middle_query_t
3434
{
3535
public:
3636
middle_query_pgsql_t(
37-
std::string const &conninfo,
38-
std::shared_ptr<node_locations_t> const &cache,
39-
std::shared_ptr<node_persistent_cache> const &persistent_cache);
37+
std::string const &conninfo, std::shared_ptr<node_locations_t> cache,
38+
std::shared_ptr<node_persistent_cache> persistent_cache);
4039

4140
size_t nodes_get_list(osmium::WayNodeList *nodes) const override;
4241

src/output.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ output_t::create_output(std::shared_ptr<middle_query_t> const &mid,
6363
"gazetteer, null]."_format(options.output_backend)};
6464
}
6565

66-
output_t::output_t(std::shared_ptr<middle_query_t> const &mid,
66+
output_t::output_t(std::shared_ptr<middle_query_t> mid,
6767
std::shared_ptr<thread_pool_t> thread_pool,
6868
options_t const &options)
69-
: m_mid(mid), m_thread_pool(std::move(thread_pool)), m_options(options)
69+
: m_mid(std::move(mid)), m_thread_pool(std::move(thread_pool)),
70+
m_options(options)
7071
{}
7172

7273
output_t::~output_t() = default;

src/output.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class output_t
3737
std::shared_ptr<thread_pool_t> thread_pool,
3838
options_t const &options);
3939

40-
output_t(std::shared_ptr<middle_query_t> const &mid,
40+
output_t(std::shared_ptr<middle_query_t> mid,
4141
std::shared_ptr<thread_pool_t> thread_pool,
4242
options_t const &options);
4343

src/table.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
#include "taginfo.hpp"
2424
#include "util.hpp"
2525

26-
table_t::table_t(std::string const &name, std::string const &type,
27-
columns_t const &columns, hstores_t const &hstore_columns,
28-
int const srid, bool const append, hstore_column hstore_mode,
26+
table_t::table_t(std::string const &name, std::string type, columns_t columns,
27+
hstores_t hstore_columns, int const srid, bool const append,
28+
hstore_column hstore_mode,
2929
std::shared_ptr<db_copy_thread_t> const &copy_thread,
3030
std::string const &schema)
3131
: m_target(std::make_shared<db_target_descr_t>(name.c_str(), "osm_id")),
32-
m_type(type), m_srid(fmt::to_string(srid)), m_append(append),
33-
m_hstore_mode(hstore_mode), m_columns(columns),
34-
m_hstore_columns(hstore_columns), m_copy(copy_thread)
32+
m_type(std::move(type)), m_srid(fmt::to_string(srid)), m_append(append),
33+
m_hstore_mode(hstore_mode), m_columns(std::move(columns)),
34+
m_hstore_columns(std::move(hstore_columns)), m_copy(copy_thread)
3535
{
3636
m_target->schema = schema;
3737

src/table.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ using hstores_t = std::vector<std::string>;
2727
class table_t
2828
{
2929
public:
30-
table_t(std::string const &name, std::string const &type,
31-
columns_t const &columns, hstores_t const &hstore_columns, int srid,
32-
bool append, hstore_column hstore_mode,
30+
table_t(std::string const &name, std::string type, columns_t columns,
31+
hstores_t hstore_columns, int srid, bool append,
32+
hstore_column hstore_mode,
3333
std::shared_ptr<db_copy_thread_t> const &copy_thread,
3434
std::string const &schema);
35+
3536
table_t(table_t const &other,
3637
std::shared_ptr<db_copy_thread_t> const &copy_thread);
3738

src/taginfo.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ enum class ColumnType
2222

2323
struct Column
2424
{
25-
Column(std::string const &n, std::string const &tn, ColumnType t)
26-
: name(n), type_name(tn), type(t)
25+
Column(std::string n, std::string tn, ColumnType t)
26+
: name(std::move(n)), type_name(std::move(tn)), type(t)
2727
{}
2828

2929
std::string name;

0 commit comments

Comments
 (0)