Skip to content

Commit 5c97b76

Browse files
N-Dekkerdzenanz
authored andcommitted
STYLE: Add in-class {} initializers to classes with virtual functions
Added in-class `{}` default member initializers to data members of classes that have one or more virtual member functions. For an object that has one or more virtual member functions, the performance cost of adding a `{}` default member initializer to each of its non-static data members should be acceptable, relative to cost of the initialization of its virtual table. Follow-up to pull request #3851 commit 5e2c49f "STYLE: Add in-class `{}` member initializers to objects created by New()" (which only looked at classes that have a `itkNewMacro`).
1 parent 4a99ce9 commit 5c97b76

File tree

168 files changed

+795
-795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+795
-795
lines changed

Modules/Bridge/VTK/include/itkVTKImageExportBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class ITKVTK_EXPORT VTKImageExportBase : public ProcessObject
231231

232232
private:
233233
/** PipelineMTime from the last call to PipelineModifiedCallback. */
234-
ModifiedTimeType m_LastPipelineMTime;
234+
ModifiedTimeType m_LastPipelineMTime{};
235235
};
236236
} // end namespace itk
237237

Modules/Compatibility/Deprecated/include/itkChildTreeIterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class ITK_TEMPLATE_EXPORT ChildTreeIterator : public TreeIteratorBase<TTreeType>
8181
HasNext() const override;
8282

8383
private:
84-
mutable ChildIdentifier m_ListPosition;
85-
TreeNodeType * m_ParentNode;
84+
mutable ChildIdentifier m_ListPosition{};
85+
TreeNodeType * m_ParentNode{};
8686
};
8787

8888
} // end namespace itk

Modules/Compatibility/Deprecated/include/itkLevelOrderTreeIterator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ class ITK_TEMPLATE_EXPORT LevelOrderTreeIterator : public TreeIteratorBase<TTree
106106
int
107107
GetLevel(const TreeNodeType * node) const;
108108

109-
int m_StartLevel;
110-
int m_EndLevel;
111-
mutable std::queue<const TreeNodeType *> m_Queue;
109+
int m_StartLevel{};
110+
int m_EndLevel{};
111+
mutable std::queue<const TreeNodeType *> m_Queue{};
112112
};
113113

114114
} // end namespace itk

Modules/Compatibility/Deprecated/include/itkMutexLock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class ITKDeprecated_EXPORT SimpleMutexLock
102102
}
103103

104104
protected:
105-
MutexType m_MutexLock;
105+
MutexType m_MutexLock{};
106106
};
107107

108108
/**

Modules/Compatibility/Deprecated/include/itkTreeChangeEvent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ITK_TEMPLATE_EXPORT TreeChangeEvent : public ModifiedEvent
8585
{}
8686

8787
protected:
88-
const TreeIteratorBase<TTreeType> * m_ChangePosition;
88+
const TreeIteratorBase<TTreeType> * m_ChangePosition{};
8989
};
9090

9191
/** \class TreeNodeChangeEvent

Modules/Compatibility/Deprecated/include/itkTreeIteratorBase.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ class ITK_TEMPLATE_EXPORT TreeIteratorBase
274274
TreeIteratorBase(const TTreeType * tree, const TreeNodeType * start);
275275

276276
mutable TreeNodeType * m_Position; // Current position of the iterator
277-
mutable TreeNodeType * m_Begin;
278-
const TreeNodeType * m_Root;
279-
TTreeType * m_Tree;
277+
mutable TreeNodeType * m_Begin{};
278+
const TreeNodeType * m_Root{};
279+
TTreeType * m_Tree{};
280280

281281
virtual bool
282282
HasNext() const = 0;

Modules/Core/Common/include/itkCellInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ class ITK_TEMPLATE_EXPORT CellInterface
490490

491491
protected:
492492
/** Store the set of cells using this boundary. */
493-
UsingCellsContainer m_UsingCells;
493+
UsingCellsContainer m_UsingCells{};
494494
};
495495

496496
/** \class CellTraitsInfo

Modules/Core/Common/include/itkConditionalConstIterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ class ITK_TEMPLATE_EXPORT ConditionalConstIterator
112112
protected: // made protected so other iterators can access
113113
/** Smart pointer to the source image. */
114114
// SmartPointer<const ImageType> m_Image;
115-
typename ImageType::ConstWeakPointer m_Image;
115+
typename ImageType::ConstWeakPointer m_Image{};
116116

117117
/** Region type to iterate over. */
118-
RegionType m_Region;
118+
RegionType m_Region{};
119119

120120
/** Is the iterator at the end of its walk? */
121121
bool m_IsAtEnd{ false };

Modules/Core/Common/include/itkConstNeighborhoodIterator.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ class ITK_TEMPLATE_EXPORT ConstNeighborhoodIterator
590590
const InternalPixelType * m_Begin{ nullptr };
591591

592592
/** The image on which iteration is defined. */
593-
typename ImageType::ConstWeakPointer m_ConstImage;
593+
typename ImageType::ConstWeakPointer m_ConstImage{};
594594

595595
/** A pointer to one past the last pixel in the iteration region. */
596596
const InternalPixelType * m_End{ nullptr };
@@ -603,7 +603,7 @@ class ITK_TEMPLATE_EXPORT ConstNeighborhoodIterator
603603
IndexType m_Loop{ { 0 } };
604604

605605
/** The region over which iteration is defined. */
606-
RegionType m_Region;
606+
RegionType m_Region{};
607607

608608
/** The internal array of offsets that provide support for regions of
609609
* interest.
@@ -616,7 +616,7 @@ class ITK_TEMPLATE_EXPORT ConstNeighborhoodIterator
616616
* By default this points to m_BoundaryCondition, but
617617
* OverrideBoundaryCondition allows a user to point this variable an external
618618
* boundary condition. */
619-
ImageBoundaryConditionPointerType m_BoundaryCondition;
619+
ImageBoundaryConditionPointerType m_BoundaryCondition{};
620620

621621
/** Denotes which of the iterators dimensional sides spill outside
622622
* region of interest boundaries. By default `false` for each dimension. */
@@ -631,19 +631,19 @@ class ITK_TEMPLATE_EXPORT ConstNeighborhoodIterator
631631
mutable bool m_IsInBoundsValid{ false };
632632

633633
/** Lower threshold of in-bounds loop counter values. */
634-
IndexType m_InnerBoundsLow;
634+
IndexType m_InnerBoundsLow{};
635635

636636
/** Upper threshold of in-bounds loop counter values. */
637-
IndexType m_InnerBoundsHigh;
637+
IndexType m_InnerBoundsHigh{};
638638

639639
/** Default boundary condition. */
640-
TBoundaryCondition m_InternalBoundaryCondition;
640+
TBoundaryCondition m_InternalBoundaryCondition{};
641641

642642
/** Does the specified region need to worry about boundary conditions? */
643643
bool m_NeedToUseBoundaryCondition{ false };
644644

645645
/** Functor type used to access neighborhoods of pixel pointers */
646-
NeighborhoodAccessorFunctorType m_NeighborhoodAccessorFunctor;
646+
NeighborhoodAccessorFunctorType m_NeighborhoodAccessorFunctor{};
647647
};
648648

649649
template <typename TImage>

Modules/Core/Common/include/itkConstNeighborhoodIteratorWithOnlyIndex.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ class ITK_TEMPLATE_EXPORT ConstNeighborhoodIteratorWithOnlyIndex : public Neighb
375375
IndexType m_Bound{ { 0 } };
376376

377377
/** The image on which iteration is defined. */
378-
typename ImageType::ConstPointer m_ConstImage;
378+
typename ImageType::ConstPointer m_ConstImage{};
379379

380380
/** The end index for iteration within the itk::Image region
381381
* on which this ConstNeighborhoodIteratorWithOnlyIndex is defined. */
@@ -385,7 +385,7 @@ class ITK_TEMPLATE_EXPORT ConstNeighborhoodIteratorWithOnlyIndex : public Neighb
385385
IndexType m_Loop{ { 0 } };
386386

387387
/** The region over which iteration is defined. */
388-
RegionType m_Region;
388+
RegionType m_Region{};
389389

390390
/** Denotes which of the iterators dimensional sides spill outside
391391
* region of interest boundaries. By default `false` for each dimension. */
@@ -400,10 +400,10 @@ class ITK_TEMPLATE_EXPORT ConstNeighborhoodIteratorWithOnlyIndex : public Neighb
400400
mutable bool m_IsInBoundsValid{ false };
401401

402402
/** Lower threshold of in-bounds loop counter values. */
403-
IndexType m_InnerBoundsLow;
403+
IndexType m_InnerBoundsLow{};
404404

405405
/** Upper threshold of in-bounds loop counter values. */
406-
IndexType m_InnerBoundsHigh;
406+
IndexType m_InnerBoundsHigh{};
407407

408408
/** Does the specified region need to worry about boundary conditions? */
409409
bool m_NeedToUseBoundaryCondition{ false };

0 commit comments

Comments
 (0)