Skip to content

Commit 203889c

Browse files
committed
Avoid copy of vector in get_tiles_from_table() function
Use out parameter with ptr instead.
1 parent 6746e54 commit 203889c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/gen/osm2pgsql-gen.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,15 @@ static tile_extent get_extent_from_db(pg_conn_t const &db_connection,
200200
return get_extent_from_db(db_connection, schema, table, geom_column, zoom);
201201
}
202202

203-
static std::vector<std::pair<uint32_t, uint32_t>>
203+
static void
204204
get_tiles_from_table(pg_conn_t const &connection, std::string const &table,
205-
uint32_t zoom)
205+
uint32_t zoom,
206+
std::vector<std::pair<uint32_t, uint32_t>> *tiles)
206207
{
207208
auto const result = connection.exec(
208209
R"(SELECT x, y FROM "{}" WHERE zoom = {})", table, zoom);
209210

210-
std::vector<std::pair<uint32_t, uint32_t>> tiles;
211-
tiles.reserve(result.num_tuples());
211+
tiles->reserve(result.num_tuples());
212212

213213
uint32_t const max = 1UL << zoom;
214214
for (int n = 0; n < result.num_tuples(); ++n) {
@@ -223,10 +223,8 @@ get_tiles_from_table(pg_conn_t const &connection, std::string const &table,
223223
log_error("Ignoring invalid y value in expire table '{}'", table);
224224
continue;
225225
}
226-
tiles.emplace_back(x, y);
226+
tiles->emplace_back(x, y);
227227
}
228-
229-
return tiles;
230228
}
231229

232230
class tile_processor_t
@@ -509,7 +507,7 @@ class genproc_t
509507
auto const table = params.get_string("expire_list");
510508
log_debug("Running generalizer for expire list from table '{}'...",
511509
table);
512-
tile_list = get_tiles_from_table(db_connection, table, zoom);
510+
get_tiles_from_table(db_connection, table, zoom, &tile_list);
513511
log_debug("Truncating table '{}'...", table);
514512
db_connection.exec("TRUNCATE {}", table);
515513
} else {

0 commit comments

Comments
 (0)