Skip to content

Commit

Permalink
STYLE: Replace (*p).member with p->member in library code
Browse files Browse the repository at this point in the history
Simplified code by using the arrow operator, instead of using parentheses,
asterisk and dot operators.

Did so by replacing the regular expression `\(\*(\w+)\)\.` with `$1->`, followed
by a few manual fixes.
  • Loading branch information
N-Dekker authored and hjmjohnson committed Jul 31, 2022
1 parent 8d31970 commit d90e635
Show file tree
Hide file tree
Showing 58 changed files with 426 additions and 428 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class TreeIteratorClone
Print(std::ostream & os) const
{
// This prints the object pointed to by the pointer
(*m_Pointer).Print(os);
m_Pointer->Print(os);
return m_Pointer;
}

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkAutoPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class AutoPointer
/* ObjectType *Print (std::ostream& os) const
{
// This prints the object pointed to by the pointer
(*m_Pointer).Print(os);
m_Pointer->Print(os);
os << "Owner: " << m_IsOwner << std::endl;
return m_Pointer;
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkCellInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class ITK_TEMPLATE_EXPORT CellInterface
auto pos = m_UserDefined.find(id);
if (pos != m_UserDefined.end())
{
return (*pos).second;
return pos->second;
}
}
return nullptr;
Expand Down
16 changes: 8 additions & 8 deletions Modules/Core/Common/include/itkCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ITK_TEMPLATE_EXPORT MemberCommand : public Command
{
if (m_MemberFunction)
{
((*m_This).*(m_MemberFunction))(caller, event);
(m_This->*(m_MemberFunction))(caller, event);
}
}

Expand All @@ -134,7 +134,7 @@ class ITK_TEMPLATE_EXPORT MemberCommand : public Command
{
if (m_ConstMemberFunction)
{
((*m_This).*(m_ConstMemberFunction))(caller, event);
(m_This->*(m_ConstMemberFunction))(caller, event);
}
}

Expand Down Expand Up @@ -195,7 +195,7 @@ class ITK_TEMPLATE_EXPORT ReceptorMemberCommand : public Command
{
if (m_MemberFunction)
{
((*m_This).*(m_MemberFunction))(event);
(m_This->*(m_MemberFunction))(event);
}
}

Expand All @@ -205,7 +205,7 @@ class ITK_TEMPLATE_EXPORT ReceptorMemberCommand : public Command
{
if (m_MemberFunction)
{
((*m_This).*(m_MemberFunction))(event);
(m_This->*(m_MemberFunction))(event);
}
}

Expand Down Expand Up @@ -263,7 +263,7 @@ class ITK_TEMPLATE_EXPORT SimpleMemberCommand : public Command
{
if (m_MemberFunction)
{
((*m_This).*(m_MemberFunction))();
(m_This->*(m_MemberFunction))();
}
}

Expand All @@ -272,7 +272,7 @@ class ITK_TEMPLATE_EXPORT SimpleMemberCommand : public Command
{
if (m_MemberFunction)
{
((*m_This).*(m_MemberFunction))();
(m_This->*(m_MemberFunction))();
}
}

Expand Down Expand Up @@ -330,7 +330,7 @@ class ITK_TEMPLATE_EXPORT SimpleConstMemberCommand : public Command
{
if (m_MemberFunction)
{
((*m_This).*(m_MemberFunction))();
(m_This->*(m_MemberFunction))();
}
}

Expand All @@ -339,7 +339,7 @@ class ITK_TEMPLATE_EXPORT SimpleConstMemberCommand : public Command
{
if (m_MemberFunction)
{
((*m_This).*(m_MemberFunction))();
(m_This->*(m_MemberFunction))();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkEquivalencyTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class ITKCommon_EXPORT EquivalencyTable : public DataObject
}
else
{
return (*result).second;
return result->second;
}
}

Expand Down
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkPriorityQueueContainer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typename ElementWrapperPointerInterface<TElementWrapperPointer, TElementIdentifi
ElementWrapperPointerInterface<TElementWrapperPointer, TElementIdentifier>::GetLocation(
const ElementWrapperPointerType & element) const
{
return ((*element).GetLocation(*element));
return (element->GetLocation(*element));
}
// -----------------------------------------------------------------------------

Expand All @@ -50,7 +50,7 @@ ElementWrapperPointerInterface<TElementWrapperPointer, TElementIdentifier>::SetL
ElementWrapperPointerType & element,
const ElementIdentifierType & identifier)
{
(*element).SetLocation(*element, identifier);
element->SetLocation(*element, identifier);
}
// -----------------------------------------------------------------------------

Expand All @@ -61,7 +61,7 @@ ElementWrapperPointerInterface<TElementWrapperPointer, TElementIdentifier>::is_l
const ElementWrapperPointerType & element1,
const ElementWrapperPointerType & element2) const
{
return ((*element1).is_less((*element1), (*element2)));
return (element1->is_less((*element1), (*element2)));
}
// -----------------------------------------------------------------------------

Expand All @@ -72,7 +72,7 @@ ElementWrapperPointerInterface<TElementWrapperPointer, TElementIdentifier>::is_g
const ElementWrapperPointerType & element1,
const ElementWrapperPointerType & element2) const
{
return ((*element1).is_greater((*element1), (*element2)));
return (element1->is_greater((*element1), (*element2)));
}
// -----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkSmartPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class SmartPointer
else
{
// This prints the object pointed to by the pointer
(*m_Pointer).Print(os);
m_Pointer->Print(os);
}
return m_Pointer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ T *
SmartPointerForwardReference<T>::Print(std::ostream & os) const
{
// This prints the object pointed to by the pointer
(*m_Pointer).Print(os);
m_Pointer->Print(os);
return m_Pointer;
}

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkWeakPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class WeakPointer
else
{
// This prints the object pointed to by the pointer
(*m_Pointer).Print(os);
m_Pointer->Print(os);
}
return m_Pointer;
}
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/src/itkEquivalencyTable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ EquivalencyTable::AddAndFlatten(unsigned long a, unsigned long b)
// ConstIterator it = this->Begin();
// while (it != this->End() )
// {
// std::cout << (*it).first << " = " << (*it).second << std::endl;
// std::cout << it->first << " = " << it->second << std::endl;
// ++it;
// }
//}
Expand All @@ -111,7 +111,7 @@ EquivalencyTable::Flatten()

while (it != this->End())
{
(*it).second = this->RecursiveLookup((*it).second);
it->second = this->RecursiveLookup(it->second);
++it;
}
}
Expand All @@ -127,7 +127,7 @@ EquivalencyTable::RecursiveLookup(const unsigned long a) const

while ((it = m_HashMap.find(ans)) != hashEnd)
{
ans = (*it).second;
ans = it->second;
if (ans == a)
{
return last_ans; // about to cycle again.
Expand Down
10 changes: 5 additions & 5 deletions Modules/Core/Common/src/itkLoggerManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ LoggerManager::SetPriorityLevel(PriorityLevelEnum level)

while (itr != this->m_LoggerSet.end())
{
(*itr).second->SetPriorityLevel(level);
itr->second->SetPriorityLevel(level);
++itr;
}
}
Expand All @@ -84,7 +84,7 @@ LoggerManager::SetLevelForFlushing(PriorityLevelEnum level)

while (itr != this->m_LoggerSet.end())
{
(*itr).second->SetLevelForFlushing(level);
itr->second->SetLevelForFlushing(level);
++itr;
}
}
Expand All @@ -96,7 +96,7 @@ LoggerManager::AddLogOutput(OutputType * output)

while (itr != this->m_LoggerSet.end())
{
(*itr).second->AddLogOutput(output);
itr->second->AddLogOutput(output);
++itr;
}
}
Expand All @@ -108,7 +108,7 @@ LoggerManager::Write(PriorityLevelEnum level, std::string const & content)

while (itr != this->m_LoggerSet.end())
{
(*itr).second->Write(level, content);
itr->second->Write(level, content);
++itr;
}
}
Expand All @@ -120,7 +120,7 @@ LoggerManager::Flush()

while (itr != this->m_LoggerSet.end())
{
(*itr).second->Flush();
itr->second->Flush();
++itr;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/src/itkMetaDataDictionary.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ MetaDataDictionary::Print(std::ostream & os) const
os << "Dictionary use_count: " << m_Dictionary.use_count() << std::endl;
for (MetaDataDictionaryMapType::const_iterator it = m_Dictionary->begin(); it != m_Dictionary->end(); ++it)
{
os << (*it).first << " ";
(*it).second->Print(os);
os << it->first << " ";
it->second->Print(os);
}
}

Expand Down Expand Up @@ -102,7 +102,7 @@ MetaDataDictionary::GetKeys() const

for (MetaDataDictionaryMapType::const_iterator it = m_Dictionary->begin(); it != m_Dictionary->end(); ++it)
{
ans.push_back((*it).first);
ans.push_back(it->first);
}

return ans;
Expand Down
18 changes: 9 additions & 9 deletions Modules/Core/Common/src/itkObjectFactoryBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,9 @@ ObjectFactoryBase::CreateObject(const char * itkclassname)

for (auto i = start; i != end; ++i)
{
if (i != m_OverrideMap->end() && (*i).second.m_EnabledFlag)
if (i != m_OverrideMap->end() && i->second.m_EnabledFlag)
{
return (*i).second.m_CreateObject->CreateObject();
return i->second.m_CreateObject->CreateObject();
}
}
return nullptr;
Expand All @@ -800,9 +800,9 @@ ObjectFactoryBase::CreateAllObject(const char * itkclassname)

for (auto i = start; i != end; ++i)
{
if (i != m_OverrideMap->end() && (*i).second.m_EnabledFlag)
if (i != m_OverrideMap->end() && i->second.m_EnabledFlag)
{
created.push_back((*i).second.m_CreateObject->CreateObject());
created.push_back(i->second.m_CreateObject->CreateObject());
}
}
return created;
Expand All @@ -819,9 +819,9 @@ ObjectFactoryBase::SetEnableFlag(bool flag, const char * className, const char *

for (auto i = start; i != end; ++i)
{
if ((*i).second.m_OverrideWithName == subclassName)
if (i->second.m_OverrideWithName == subclassName)
{
(*i).second.m_EnabledFlag = flag;
i->second.m_EnabledFlag = flag;
}
}
}
Expand All @@ -837,9 +837,9 @@ ObjectFactoryBase::GetEnableFlag(const char * className, const char * subclassNa

for (auto i = start; i != end; ++i)
{
if ((*i).second.m_OverrideWithName == subclassName)
if (i->second.m_OverrideWithName == subclassName)
{
return (*i).second.m_EnabledFlag;
return i->second.m_EnabledFlag;
}
}
return false;
Expand All @@ -856,7 +856,7 @@ ObjectFactoryBase::Disable(const char * className)

for (auto i = start; i != end; ++i)
{
(*i).second.m_EnabledFlag = false;
i->second.m_EnabledFlag = false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ DTITubeSpatialObjectPoint<TPointDimension>::DTITubeSpatialObjectPoint(const DTIT
auto it = fields.begin();
while (it != fields.end())
{
this->AddField((*it).first.c_str(), (*it).second);
this->AddField(it->first.c_str(), it->second);
++it;
}
for (unsigned int i = 0; i < 6; ++i)
Expand Down Expand Up @@ -102,9 +102,9 @@ DTITubeSpatialObjectPoint<TPointDimension>::SetField(const char * name, float va

while (it != m_Fields.end())
{
if (!strcmp((*it).first.c_str(), itksys::SystemTools::LowerCase(name).c_str()))
if (!strcmp(it->first.c_str(), itksys::SystemTools::LowerCase(name).c_str()))
{
(*it).second = value;
it->second = value;
}
++it;
}
Expand Down Expand Up @@ -154,9 +154,9 @@ DTITubeSpatialObjectPoint<TPointDimension>::GetField(const char * name) const

while (it != m_Fields.end())
{
if (!strcmp((*it).first.c_str(), itksys::SystemTools::LowerCase(name).c_str()))
if (!strcmp(it->first.c_str(), itksys::SystemTools::LowerCase(name).c_str()))
{
return (*it).second;
return it->second;
}
++it;
}
Expand Down Expand Up @@ -189,7 +189,7 @@ DTITubeSpatialObjectPoint<TPointDimension>::operator=(const DTITubeSpatialObject
auto it = fields.begin();
while (it != fields.end())
{
this->AddField((*it).first.c_str(), (*it).second);
this->AddField(it->first.c_str(), it->second);
++it;
}
for (unsigned int i = 0; i < 6; ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ LineSpatialObject<TDimension>::IsInsideInObjectSpace(const PointType & point) co
bool match = true;
for (unsigned int i = 0; i < TDimension; ++i)
{
if (!Math::AlmostEquals((*it).GetPositionInObjectSpace()[i], point[i]))
if (!Math::AlmostEquals(it->GetPositionInObjectSpace()[i], point[i]))
{
match = false;
break;
Expand Down
10 changes: 5 additions & 5 deletions Modules/Core/SpatialObjects/include/itkMetaBlobConverter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ MetaBlobConverter<VDimension>::SpatialObjectToMetaObject(const SpatialObjectType

for (unsigned int d = 0; d < VDimension; ++d)
{
pnt->m_X[d] = (*it).GetPositionInObjectSpace()[d];
pnt->m_X[d] = it->GetPositionInObjectSpace()[d];
}

pnt->m_Color[0] = (*it).GetRed();
pnt->m_Color[1] = (*it).GetGreen();
pnt->m_Color[2] = (*it).GetBlue();
pnt->m_Color[3] = (*it).GetAlpha();
pnt->m_Color[0] = it->GetRed();
pnt->m_Color[1] = it->GetGreen();
pnt->m_Color[2] = it->GetBlue();
pnt->m_Color[3] = it->GetAlpha();

Blob->GetPoints().push_back(pnt);
}
Expand Down
Loading

0 comments on commit d90e635

Please sign in to comment.