Skip to content

PERF: Use initializer list in ShapedImageNeighborhoodRange operator* - #144

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:masterfrom
thewtex:neighborhood-range-initializer-list
Nov 7, 2018
Merged

PERF: Use initializer list in ShapedImageNeighborhoodRange operator*#144
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:masterfrom
thewtex:neighborhood-range-initializer-list

Conversation

@thewtex

@thewtex thewtex commented Nov 7, 2018

Copy link
Copy Markdown
Member

Results in ~10% performance increase.

@N-Dekker this came up when testing the new constant boundary condition in ITKUltrasound.

reference operator*() const ITK_NOEXCEPT
{
return reference(m_ImageBufferPointer, m_ImageSize, m_OffsetTable, m_NeighborhoodAccessor, m_Location + *m_CurrentOffset);
return reference{m_ImageBufferPointer, m_ImageSize, m_OffsetTable, m_NeighborhoodAccessor, m_Location + *m_CurrentOffset};

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.

I'm fine with using curly braces instead of parentheses, but it only looks like a STYLE issue to me. (Actually I originally wanted to use curly braces on that line of code but KWStyle complained, at that time. If I remember correctly!) So are you sure that this change really has such an impact on the performance? If so, do you have a clue why?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, older versions of KWStyle will complain about }; 😞 , but this has been fixed in newer versions ☀️ .

I did observe the speed up, but I do not know the details of why this makes a difference to the compiler.

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.

Glad to hear KWStyle no longer complains about this }; syntax!

With which specific compiler version did you observe the speed-up? Because it sounds like a compiler issue to me! I just tried, but did not observe a significant performance difference between curly braces and parentheses on VS2017 (Version 15.8.9).

Anyway, the code change you're proposing here is perfectly fine to me.

@hjmjohnson
hjmjohnson merged commit 3991369 into InsightSoftwareConsortium:master Nov 7, 2018
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request Apr 19, 2026
Fix the crash when 3D tile configuration has only a single layer
hjmjohnson pushed a commit that referenced this pull request Apr 25, 2026
Fix the crash when 3D tile configuration has only a single layer
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
Fix the crash when 3D tile configuration has only a single layer
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 12, 2026
Fix the crash when 3D tile configuration has only a single layer
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 14, 2026
…/rename_structure_tensor

Style: Rename itkStructureTensor to itkStructureTensorImageFilter
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 14, 2026
…/rename_structure_tensor

Style: Rename itkStructureTensor to itkStructureTensorImageFilter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants