Skip to content

Commit

Permalink
Ref don't copy
Browse files Browse the repository at this point in the history
  • Loading branch information
rschlaikjer committed Dec 5, 2023
1 parent 2e42bb9 commit 7102a60
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libopenrave/kinbodygrab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ void KinBody::GetGrabbedInfo(std::vector<KinBody::GrabbedInfoPtr>& vGrabbedInfos
vGrabbedInfos.reserve(_vGrabbedBodies.size());
vGrabbedInfos.clear();
for(size_t i = 0; i < _vGrabbedBodies.size(); ++i) {
GrabbedConstPtr pgrabbed = _vGrabbedBodies[i];
const GrabbedPtr& pgrabbed = _vGrabbedBodies[i];
KinBodyPtr pgrabbedbody = pgrabbed->_pGrabbedBody.lock();
// sometimes bodies can be removed before they are Released, this is ok and can happen during exceptions and stack unwinding
if( !!pgrabbedbody ) {
Expand All @@ -609,7 +609,7 @@ void KinBody::GetGrabbedInfo(std::vector<KinBody::GrabbedInfoPtr>& vGrabbedInfos
poutputinfo->_setIgnoreRobotLinkNames.insert((*itlink)->GetName());
}
}
vGrabbedInfos.push_back(poutputinfo);
vGrabbedInfos.emplace_back(std::move(poutputinfo));
}
}
}
Expand All @@ -620,7 +620,7 @@ void KinBody::GetGrabbedInfo(std::vector<GrabbedInfo>& vGrabbedInfos) const
for(size_t igrabbed = 0; igrabbed < _vGrabbedBodies.size(); ++igrabbed) {
vGrabbedInfos[igrabbed].Reset(); /// have to reset everything

GrabbedConstPtr pgrabbed = _vGrabbedBodies[igrabbed];
const GrabbedPtr& pgrabbed = _vGrabbedBodies[igrabbed];
KinBodyPtr pgrabbedbody = pgrabbed->_pGrabbedBody.lock();
// sometimes bodies can be removed before they are Released, this is ok and can happen during exceptions and stack unwinding
if( !!pgrabbedbody ) {
Expand All @@ -644,7 +644,7 @@ bool KinBody::GetGrabbedInfo(const std::string& grabbedname, GrabbedInfo& grabbe
{
grabbedInfo.Reset();
for(size_t igrabbed = 0; igrabbed < _vGrabbedBodies.size(); ++igrabbed) {
GrabbedConstPtr pgrabbed = _vGrabbedBodies[igrabbed];
const GrabbedPtr& pgrabbed = _vGrabbedBodies[igrabbed];
if( !!pgrabbed ) {
KinBodyPtr pgrabbedbody = pgrabbed->_pGrabbedBody.lock();
if( !!pgrabbedbody && pgrabbedbody->GetName() == grabbedname ) {
Expand Down

0 comments on commit 7102a60

Please sign in to comment.