Skip to content

Commit db36f4c

Browse files
authored
Merge pull request #1467 from joto/expire-code-cleanup
Directly use std::string reference instead of calling c_str()
2 parents bf4d427 + 404c38e commit db36f4c

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/expire-tiles.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ int expire_tiles::from_bbox(double min_lon, double min_lat, double max_lon,
265265
return 0;
266266
}
267267

268-
void expire_tiles::from_wkb(char const *wkb, osmid_t osm_id)
268+
void expire_tiles::from_wkb(std::string const &wkb, osmid_t osm_id)
269269
{
270270
if (maxzoom == 0) {
271271
return;
272272
}
273273

274-
auto parse = ewkb::parser_t(wkb);
274+
ewkb::parser_t parse{wkb};
275275

276276
switch (parse.read_header()) {
277277
case ewkb::wkb_point:
@@ -401,7 +401,7 @@ int expire_tiles::from_db(table_t *table, osmid_t osm_id)
401401
char const *wkb = nullptr;
402402
while ((wkb = wkbs.get_next())) {
403403
auto const binwkb = ewkb::parser_t::wkb_from_hex(wkb);
404-
from_wkb(binwkb.c_str(), osm_id);
404+
from_wkb(binwkb, osm_id);
405405
}
406406

407407
//return how many rows were affected
@@ -420,7 +420,7 @@ int expire_tiles::from_result(pg_result_t const &result, osmid_t osm_id)
420420
for (int i = 0; i < num_tuples; ++i) {
421421
char const *const wkb = result.get_value(i, 0);
422422
auto const binwkb = ewkb::parser_t::wkb_from_hex(wkb);
423-
from_wkb(binwkb.c_str(), osm_id);
423+
from_wkb(binwkb, osm_id);
424424
}
425425

426426
//return how many rows were affected

src/expire-tiles.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct expire_tiles
6464

6565
int from_bbox(double min_lon, double min_lat, double max_lon,
6666
double max_lat);
67-
void from_wkb(char const *wkb, osmid_t osm_id);
67+
void from_wkb(std::string const &wkb, osmid_t osm_id);
6868
int from_db(table_t *table, osmid_t osm_id);
6969
int from_result(pg_result_t const &result, osmid_t osm_id);
7070

src/output-flex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ void output_flex_t::add_row(table_connection_t *table_connection,
10531053
auto const wkbs =
10541054
run_transform(builder, transform, table.geom_column().type(), object);
10551055
for (auto const &wkb : wkbs) {
1056-
m_expire.from_wkb(wkb.c_str(), id);
1056+
m_expire.from_wkb(wkb, id);
10571057
write_row(table_connection, object.type(), id, wkb,
10581058
table.geom_column().srid());
10591059
}

src/output-pgsql.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void output_pgsql_t::pgsql_out_way(osmium::Way const &way, taglist_t *tags,
5050
if (polygon && way.is_closed()) {
5151
auto wkb = m_builder.get_wkb_polygon(way);
5252
if (!wkb.empty()) {
53-
expire.from_wkb(wkb.c_str(), way.id());
53+
expire.from_wkb(wkb, way.id());
5454
if (m_enable_way_area) {
5555
auto const area =
5656
m_options.reproject_area
@@ -67,7 +67,7 @@ void output_pgsql_t::pgsql_out_way(osmium::Way const &way, taglist_t *tags,
6767
double const split_at =
6868
m_options.projection->target_latlon() ? 1 : 100 * 1000;
6969
for (auto const &wkb : m_builder.get_wkb_line(way.nodes(), split_at)) {
70-
expire.from_wkb(wkb.c_str(), way.id());
70+
expire.from_wkb(wkb, way.id());
7171
m_tables[t_line]->write_row(way.id(), *tags, wkb);
7272
if (roads) {
7373
m_tables[t_roads]->write_row(way.id(), *tags, wkb);
@@ -143,7 +143,7 @@ void output_pgsql_t::node_add(osmium::Node const &node)
143143
}
144144

145145
auto wkb = m_builder.get_wkb_node(node.location());
146-
expire.from_wkb(wkb.c_str(), node.id());
146+
expire.from_wkb(wkb, node.id());
147147
m_tables[t_point]->write_row(node.id(), outtags, wkb);
148148
}
149149

@@ -206,7 +206,7 @@ void output_pgsql_t::pgsql_process_relation(osmium::Relation const &rel)
206206
m_options.projection->target_latlon() ? 1 : 100 * 1000;
207207
auto wkbs = m_builder.get_wkb_multiline(buffer, split_at);
208208
for (auto const &wkb : wkbs) {
209-
expire.from_wkb(wkb.c_str(), -rel.id());
209+
expire.from_wkb(wkb, -rel.id());
210210
m_tables[t_line]->write_row(-rel.id(), outtags, wkb);
211211
if (roads) {
212212
m_tables[t_roads]->write_row(-rel.id(), outtags, wkb);
@@ -219,7 +219,7 @@ void output_pgsql_t::pgsql_process_relation(osmium::Relation const &rel)
219219
auto wkbs = m_builder.get_wkb_multipolygon(rel, buffer, m_options.enable_multi);
220220

221221
for (auto const &wkb : wkbs) {
222-
expire.from_wkb(wkb.c_str(), -rel.id());
222+
expire.from_wkb(wkb, -rel.id());
223223
if (m_enable_way_area) {
224224
auto const area =
225225
m_options.reproject_area

0 commit comments

Comments
 (0)