Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Modules/Core/Common/include/itkImageConstIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,22 @@ class ITK_TEMPLATE_EXPORT ImageConstIterator
return (m_Buffer + m_Offset) > (it.m_Buffer + it.m_Offset);
}

/** Get the index. This provides a read only reference to the index.
* This causes the index to be calculated from pointer arithmetic and is
* therefore an expensive operation.
/** Computes the index. Internally calls ImageBase::ComputeIndex, which may be a relatively expensive operation.
* \sa SetIndex */
[[nodiscard]] IndexType
ComputeIndex() const
{
return m_Image->ComputeIndex(static_cast<OffsetValueType>(m_Offset));
}

/** Computes and returns the index. This may be a relatively expensive operation.
* \note It is often preferable for users to call ComputeIndex() directly, to make it more clear that this function
* may be expensive.
* \sa ComputeIndex */
const IndexType
GetIndex() const
Comment on lines 310 to 311
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 const return-by-value inconsistency with ComputeIndex()

GetIndex() returns const IndexType while the new ComputeIndex() (which it wraps) returns plain IndexType. A top-level const on a return-by-value type is discarded by the type system and can inhibit move semantics, so the two signatures are inconsistent without benefit. Since GetIndex() is the legacy entry point this is pre-existing, but the asymmetry is now more visible next to the preferred ComputeIndex():

Suggested change
const IndexType
GetIndex() const
IndexType
GetIndex() const

{
return m_Image->ComputeIndex(static_cast<OffsetValueType>(m_Offset));
return this->ComputeIndex();
}
Comment on lines +306 to 314
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing \sa SetIndex cross-reference breaks bidirectional Doxygen link

SetIndex() still cross-references GetIndex() (\sa GetIndex), but after this change GetIndex() only cross-references ComputeIndex() — the reciprocal pointer to SetIndex is gone. Consider adding it back:

Suggested change
/** Computes and returns the index. This may be a relatively expensive operation.
* \note It is often preferable for users to call ComputeIndex() directly, to make it more clear that this function
* may be expensive.
* \sa ComputeIndex */
const IndexType
GetIndex() const
{
return m_Image->ComputeIndex(static_cast<OffsetValueType>(m_Offset));
return this->ComputeIndex();
}
/** Computes and returns the index. This may be a relatively expensive operation.
* \note It is often preferable for users to call ComputeIndex() directly, to make it more clear that this function
* may be expensive.
* \sa ComputeIndex
* \sa SetIndex */
const IndexType
GetIndex() const
{
return this->ComputeIndex();
}


/** Set the index. No bounds checking is performed.
Expand Down
Loading