Skip to content

Commit ec0ce91

Browse files
committed
Creating a point geometry_t from a point_t doesn't need move
Because point_t is small and trivially copyable. This makes code a bit simpler and avoids some warnings from clang-tidy.
1 parent 6b286d1 commit ec0ce91

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/geom.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,10 @@ class geometry_t
246246
public:
247247
constexpr geometry_t() = default;
248248

249-
constexpr explicit geometry_t(point_t &&geom, int srid = 4326)
250-
: m_geom(geom), m_srid(srid) // geom is trivially copyable, no move needed
249+
// point_t is small and trivially copyable, no move needed like for the
250+
// other constructors.
251+
constexpr explicit geometry_t(point_t geom, int srid = 4326)
252+
: m_geom(geom), m_srid(srid)
251253
{}
252254

253255
constexpr explicit geometry_t(linestring_t &&geom, int srid = 4326)

tests/test-geom-multipoints.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ TEST_CASE("multipoint_t with a single point", "[NoDB]")
3434
REQUIRE(area(geom) == Approx(0.0));
3535
REQUIRE(length(geom) == Approx(0.0));
3636
REQUIRE(reverse(geom) == geom);
37-
REQUIRE(centroid(geom) == geom::geometry_t{std::move(point)});
37+
REQUIRE(centroid(geom) == geom::geometry_t{point});
3838

3939
REQUIRE(mp[0] == expected);
4040
}
@@ -63,9 +63,9 @@ TEST_CASE("multipoint_t with several points", "[NoDB]")
6363
REQUIRE(mp[1] == p1);
6464
REQUIRE(mp[2] == p2);
6565

66-
REQUIRE(geometry_n(geom, 1) == geom::geometry_t{std::move(p0)});
67-
REQUIRE(geometry_n(geom, 2) == geom::geometry_t{std::move(p1)});
68-
REQUIRE(geometry_n(geom, 3) == geom::geometry_t{std::move(p2)});
66+
REQUIRE(geometry_n(geom, 1) == geom::geometry_t{p0});
67+
REQUIRE(geometry_n(geom, 2) == geom::geometry_t{p1});
68+
REQUIRE(geometry_n(geom, 3) == geom::geometry_t{p2});
6969
}
7070

7171
TEST_CASE("create_multipoint from OSM data", "[NoDB]")

tests/test-geom-output.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ TEST_CASE("point_t output", "[NoDB]")
3333
ss1 << g;
3434
CHECK(ss1.str() == "1 2");
3535

36-
geom::geometry_t geom{std::move(g)};
36+
geom::geometry_t geom{g};
3737
std::stringstream ss2;
3838
ss2 << geom;
3939
CHECK(ss2.str() == "POINT(1 2)");

0 commit comments

Comments
 (0)