help compiler to apply RVO ( return the same object by value)

This commit is contained in:
artemp 2015-04-08 13:10:22 +02:00
parent 431c581759
commit 310865a0c3

View file

@ -170,82 +170,75 @@ struct geom_reproj_copy_visitor {
geometry operator() (geometry_empty const&)
{
return std::move(geometry_empty());
return geometry_empty();
}
geometry operator() (point const& p)
{
geometry geom; // default empty
unsigned int intial_err = n_err_;
point new_p = reproject_internal(p, proj_trans_, n_err_);
if (n_err_ > intial_err)
{
return std::move(geometry_empty());
}
return std::move(new_p);
if (n_err_ > intial_err) return geom;
geom = std::move(new_p);
return geom;
}
geometry operator() (line_string const& ls)
{
geometry geom; // default empty
int intial_err = n_err_;
line_string new_ls = reproject_internal(ls, proj_trans_, n_err_);
if (n_err_ > intial_err || new_ls.empty())
{
return std::move(geometry_empty());
}
return std::move(new_ls);
if (n_err_ > intial_err || new_ls.empty()) return geom;
geom = std::move(new_ls);
return geom;
}
geometry operator() (polygon const& poly)
{
geometry geom; // default empty
polygon new_poly = reproject_internal(poly, proj_trans_, n_err_);
if (new_poly.exterior_ring.empty())
{
return std::move(geometry_empty());
}
return std::move(new_poly);
if (new_poly.exterior_ring.empty()) return geom;
geom = std::move(new_poly);
return geom;
}
geometry operator() (multi_point const& mp)
{
geometry geom; // default empty
multi_point new_mp = reproject_internal(mp, proj_trans_, n_err_);
if (new_mp.empty())
{
return std::move(geometry_empty());
}
return std::move(new_mp);
if (new_mp.empty()) return geom;
geom = std::move(new_mp);
return geom;
}
geometry operator() (multi_line_string const& mls)
{
geometry geom; // default empty
multi_line_string new_mls = reproject_internal(mls, proj_trans_, n_err_);
if (new_mls.empty())
{
return std::move(geometry_empty());
}
return std::move(new_mls);
if (new_mls.empty()) return geom;
geom = std::move(new_mls);
return geom;
}
geometry operator() (multi_polygon const& mpoly)
{
geometry geom; // default empty
multi_polygon new_mpoly = reproject_internal(mpoly, proj_trans_, n_err_);
if (new_mpoly.empty())
{
return std::move(geometry_empty());
}
return std::move(new_mpoly);
if (new_mpoly.empty()) return geom;
geom = std::move(new_mpoly);
return geom;
}
geometry operator() (geometry_collection const& c)
{
geometry geom; // default empty
geometry_collection new_c = reproject_internal(c, proj_trans_, n_err_);
if (new_c.empty())
{
return std::move(geometry_empty());
}
return std::move(new_c);
if (new_c.empty()) return geom;
geom = std::move(new_c);
return geom;
}
private:
private:
proj_transform const& proj_trans_;
unsigned int & n_err_;
@ -381,7 +374,7 @@ struct geom_reproj_visitor {
return true;
}
private:
private:
proj_transform const& proj_trans_;
};