Skip to content

Commit 5464539

Browse files
authored
Merge pull request #2461 from joto/lambdas
Remove reference capture from several lambdas that don't need it
2 parents e717f1b + 9c5c0c2 commit 5464539

7 files changed

Lines changed: 28 additions & 30 deletions

File tree

src/command-line-app.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void command_line_app_t::init_logging_options(bool with_progress, bool with_sql)
9797
if (with_progress) {
9898
add_option_function<std::string>(
9999
"--log-progress",
100-
[&](std::string const &arg) {
100+
[](std::string const &arg) {
101101
if (arg == "true") {
102102
get_logger().enable_progress();
103103
} else if (arg == "false") {

src/command-line-parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ options_t parse_command_line(int argc, char *argv[])
432432
options.projection =
433433
reprojection_t::create_projection(arg);
434434
#else
435-
[&](int) {
435+
[](int) {
436436
throw std::runtime_error{
437437
"Generic projections not available in this build."};
438438
#endif

src/geom-box.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ box_t envelope(geom::collection_t const &geom)
9999

100100
box_t envelope(geometry_t const &geom)
101101
{
102-
return geom.visit([&](auto const &g) { return envelope(g); });
102+
return geom.visit([](auto const &g) { return envelope(g); });
103103
}
104104

105105
} // namespace geom

src/geom-functions.cpp

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,16 @@ std::string_view geometry_type(geometry_t const &geom)
4141
{
4242
using namespace std::literals::string_view_literals;
4343
return geom.visit(overloaded{
44-
[&](geom::nullgeom_t const & /*input*/) { return "NULL"sv; },
45-
[&](geom::point_t const & /*input*/) { return "POINT"sv; },
46-
[&](geom::linestring_t const & /*input*/) { return "LINESTRING"sv; },
47-
[&](geom::polygon_t const & /*input*/) { return "POLYGON"sv; },
48-
[&](geom::multipoint_t const & /*input*/) { return "MULTIPOINT"sv; },
49-
[&](geom::multilinestring_t const & /*input*/) {
44+
[](geom::nullgeom_t const & /*input*/) { return "NULL"sv; },
45+
[](geom::point_t const & /*input*/) { return "POINT"sv; },
46+
[](geom::linestring_t const & /*input*/) { return "LINESTRING"sv; },
47+
[](geom::polygon_t const & /*input*/) { return "POLYGON"sv; },
48+
[](geom::multipoint_t const & /*input*/) { return "MULTIPOINT"sv; },
49+
[](geom::multilinestring_t const & /*input*/) {
5050
return "MULTILINESTRING"sv;
5151
},
52-
[&](geom::multipolygon_t const & /*input*/) {
53-
return "MULTIPOLYGON"sv;
54-
},
55-
[&](geom::collection_t const & /*input*/) {
52+
[](geom::multipolygon_t const & /*input*/) { return "MULTIPOLYGON"sv; },
53+
[](geom::collection_t const & /*input*/) {
5654
return "GEOMETRYCOLLECTION"sv;
5755
}});
5856
}
@@ -62,7 +60,7 @@ std::string_view geometry_type(geometry_t const &geom)
6260
std::size_t num_geometries(geometry_t const &geom)
6361
{
6462
return geom.visit(
65-
[&](auto const &input) { return input.num_geometries(); });
63+
[](auto const &input) { return input.num_geometries(); });
6664
}
6765

6866
/****************************************************************************/
@@ -353,14 +351,14 @@ geometry_t segmentize(geometry_t const &input, double max_segment_length)
353351
double area(geometry_t const &geom)
354352
{
355353
return std::abs(geom.visit(
356-
overloaded{[&](geom::nullgeom_t const & /*input*/) { return 0.0; },
357-
[&](geom::collection_t const &input) {
354+
overloaded{[](geom::nullgeom_t const & /*input*/) { return 0.0; },
355+
[](geom::collection_t const &input) {
358356
return std::accumulate(input.cbegin(), input.cend(), 0.0,
359357
[](double sum, auto const &geom) {
360358
return sum + area(geom);
361359
});
362360
},
363-
[&](auto const &input) {
361+
[](auto const &input) {
364362
return static_cast<double>(boost::geometry::area(input));
365363
}}));
366364
}
@@ -390,37 +388,37 @@ double spherical_area(geometry_t const &geom)
390388
assert(geom.srid() == PROJ_LATLONG);
391389

392390
return std::abs(geom.visit(overloaded{
393-
[&](geom::nullgeom_t const & /*input*/) { return 0.0; },
394-
[&](geom::collection_t const &input) {
391+
[](geom::nullgeom_t const & /*input*/) { return 0.0; },
392+
[](geom::collection_t const &input) {
395393
return std::accumulate(input.cbegin(), input.cend(), 0.0,
396394
[](double sum, auto const &geom) {
397395
return sum + spherical_area(geom);
398396
});
399397
},
400-
[&](geom::polygon_t const &input) { return spherical_area(input); },
401-
[&](geom::multipolygon_t const &input) {
398+
[](geom::polygon_t const &input) { return spherical_area(input); },
399+
[](geom::multipolygon_t const &input) {
402400
return std::accumulate(input.cbegin(), input.cend(), 0.0,
403-
[&](double sum, auto const &geom) {
401+
[](double sum, auto const &geom) {
404402
return sum + spherical_area(geom);
405403
});
406404
},
407-
[&](auto const & /*input*/) { return 0.0; }}));
405+
[](auto const & /*input*/) { return 0.0; }}));
408406
}
409407

410408
/****************************************************************************/
411409

412410
double length(geometry_t const &geom)
413411
{
414412
return geom.visit(overloaded{
415-
[&](geom::nullgeom_t const & /*input*/) { return 0.0; },
416-
[&](geom::collection_t const &input) {
413+
[](geom::nullgeom_t const & /*input*/) { return 0.0; },
414+
[](geom::collection_t const &input) {
417415
double total = 0.0;
418416
for (auto const &item : input) {
419417
total += length(item);
420418
}
421419
return total;
422420
},
423-
[&](auto const &input) {
421+
[](auto const &input) {
424422
return static_cast<double>(boost::geometry::length(input));
425423
}});
426424
}

src/geom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ std::size_t dimension(collection_t const &geom)
4040

4141
std::size_t dimension(geometry_t const &geom)
4242
{
43-
return geom.visit([&](auto const &input) { return dimension(input); });
43+
return geom.visit([](auto const &input) { return dimension(input); });
4444
}
4545

4646
} // namespace geom

src/locator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void locator_t::build_index()
9191
void locator_t::all_intersecting_visit(geom::geometry_t const &geom,
9292
std::set<std::string> *results)
9393
{
94-
geom.visit(overloaded{[&](geom::nullgeom_t const & /*val*/) {},
94+
geom.visit(overloaded{[](geom::nullgeom_t const & /*val*/) {},
9595
[&](geom::collection_t const &val) {
9696
for (auto const &sgeom : val) {
9797
all_intersecting_visit(sgeom, results);
@@ -120,7 +120,7 @@ std::set<std::string> locator_t::all_intersecting(geom::geometry_t const &geom)
120120
void locator_t::first_intersecting_visit(geom::geometry_t const &geom,
121121
std::string *result)
122122
{
123-
geom.visit(overloaded{[&](geom::nullgeom_t const & /*val*/) {},
123+
geom.visit(overloaded{[](geom::nullgeom_t const & /*val*/) {},
124124
[&](geom::collection_t const &val) {
125125
for (auto const &sgeom : val) {
126126
first_intersecting_visit(sgeom, result);

src/wkb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void write_collection(std::string *data, geom::collection_t const &geom,
173173

174174
for (auto const &item : geom) {
175175
item.visit(overloaded{
176-
[&](geom::nullgeom_t const & /*input*/) {},
176+
[](geom::nullgeom_t const & /*input*/) {},
177177
[&](geom::point_t const &input) { write_point(data, input); },
178178
[&](geom::linestring_t const &input) {
179179
write_linestring(data, input);

0 commit comments

Comments
 (0)