Part/Sketcher: Geometry/Geometry facade pass by const-reference instead of by value

This commit is contained in:
Abdullah Tahiri
2022-12-31 14:45:10 +01:00
committed by abdullahtahiriyo
parent b7945b6a15
commit 7fcee31c07
3 changed files with 20 additions and 16 deletions

View File

@@ -281,7 +281,7 @@ std::vector<std::weak_ptr<const GeometryExtension>> Geometry::getExtensions() co
return wp;
}
bool Geometry::hasExtension(Base::Type type) const
bool Geometry::hasExtension(const Base::Type & type) const
{
for(const auto& ext : extensions) {
if(ext->getTypeId() == type)
@@ -301,7 +301,7 @@ bool Geometry::hasExtension(const std::string & name) const
return false;
}
std::weak_ptr<GeometryExtension> Geometry::getExtension(Base::Type type)
std::weak_ptr<GeometryExtension> Geometry::getExtension(const Base::Type & type)
{
for(const auto& ext : extensions) {
if(ext->getTypeId() == type)
@@ -321,7 +321,7 @@ std::weak_ptr<GeometryExtension> Geometry::getExtension(const std::string & name
throw Base::ValueError("No geometry extension with the requested name.");
}
std::weak_ptr<const GeometryExtension> Geometry::getExtension(Base::Type type) const
std::weak_ptr<const GeometryExtension> Geometry::getExtension(const Base::Type & type) const
{
return const_cast<Geometry*>(this)->getExtension(type).lock();
}
@@ -353,7 +353,7 @@ void Geometry::setExtension(std::unique_ptr<GeometryExtension> && geoext )
}
}
void Geometry::deleteExtension(Base::Type type)
void Geometry::deleteExtension(const Base::Type & type)
{
extensions.erase(
std::remove_if( extensions.begin(),