InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.37k stars 660 forks source link

PERF: Avoid redundant searches for a data element in a `gdcm::DataSet` #4650

Closed N-Dekker closed 1 month ago

N-Dekker commented 1 month ago

The original code requested gdcm::DataSet to search for one and the same data element three times in a row, by calling both FindDataElement and GetDataElement for the very same tag. With this commit, the search is only performed once.

Issue found by Mihail Isakov (@issakomi): https://github.com/InsightSoftwareConsortium/ITK/pull/4636#discussion_r1593789757


For the record, the redundant searches appear introduced with commit 168c457e840c3ca9e7c0b6d4df4a25252a5ddc7a, June 5, 2014: https://github.com/InsightSoftwareConsortium/ITK/blob/168c457e840c3ca9e7c0b6d4df4a25252a5ddc7a/Modules/IO/GDCM/src/itkGDCMImageIO.cxx#L384-L387

N-Dekker commented 1 month ago

@dzenanz, @issakomi Thanks for your approval! I think this PR can wait until after v5.4.0. right? I just submitted the PR, so that we don't forget about it!

N-Dekker commented 1 month ago

/azp run ITK.Linux

N-Dekker commented 1 month ago

I think this pull request may also be merged now, as v5.4.0 has been tagged (https://github.com/InsightSoftwareConsortium/ITK/pull/4603#issuecomment-2120498131)