Skip to content

Commit 0907661

Browse files
blowekamphjmjohnson
authored andcommitted
PERF: Use string macro for exceptions
Add itkExceptionStringMacro which remove the usage of ostringstream, and passes argument directly to ExceptionObject.
1 parent c396195 commit 0907661

File tree

445 files changed

+1300
-1286
lines changed

Some content is hidden

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

445 files changed

+1300
-1286
lines changed

Modules/Bridge/VTK/include/itkVTKImageExport.hxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ VTKImageExport<TInputImage>::VTKImageExport()
9797
}
9898
else
9999
{
100-
itkExceptionMacro("Type currently not supported");
100+
itkExceptionStringMacro("Type currently not supported");
101101
}
102102
}
103103

@@ -141,7 +141,7 @@ VTKImageExport<TInputImage>::WholeExtentCallback()
141141

142142
if (!input)
143143
{
144-
itkExceptionMacro("Need to set an input");
144+
itkExceptionStringMacro("Need to set an input");
145145
}
146146

147147
const InputRegionType region = input->GetLargestPossibleRegion();
@@ -176,7 +176,7 @@ VTKImageExport<TInputImage>::SpacingCallback()
176176

177177
if (!input)
178178
{
179-
itkExceptionMacro("Need to set an input");
179+
itkExceptionStringMacro("Need to set an input");
180180
}
181181

182182
const typename TInputImage::SpacingType & spacing = input->GetSpacing();
@@ -233,7 +233,7 @@ VTKImageExport<TInputImage>::OriginCallback()
233233

234234
if (!input)
235235
{
236-
itkExceptionMacro("Need to set an input");
236+
itkExceptionStringMacro("Need to set an input");
237237
}
238238

239239
const typename TInputImage::PointType & origin = input->GetOrigin();
@@ -290,7 +290,7 @@ VTKImageExport<TInputImage>::DirectionCallback()
290290

291291
if (!input)
292292
{
293-
itkExceptionMacro("Need to set an input");
293+
itkExceptionStringMacro("Need to set an input");
294294
}
295295

296296
const typename TInputImage::DirectionType & direction = input->GetDirection();
@@ -363,7 +363,7 @@ VTKImageExport<TInputImage>::PropagateUpdateExtentCallback(int * extent)
363363
const InputImagePointer input = this->GetInput();
364364
if (!input)
365365
{
366-
itkExceptionMacro("Need to set an input");
366+
itkExceptionStringMacro("Need to set an input");
367367
}
368368

369369
input->SetRequestedRegion(region);
@@ -383,7 +383,7 @@ VTKImageExport<TInputImage>::DataExtentCallback()
383383

384384
if (!input)
385385
{
386-
itkExceptionMacro("Need to set an input");
386+
itkExceptionStringMacro("Need to set an input");
387387
}
388388

389389
const InputRegionType region = input->GetBufferedRegion();
@@ -416,7 +416,7 @@ VTKImageExport<TInputImage>::BufferPointerCallback()
416416

417417
if (!input)
418418
{
419-
itkExceptionMacro("Need to set an input");
419+
itkExceptionStringMacro("Need to set an input");
420420
}
421421

422422
return input->GetBufferPointer();

Modules/Bridge/VTK/include/itkVTKImageImport.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ VTKImageImport<TOutputImage>::VTKImageImport()
9292
}
9393
else
9494
{
95-
itkExceptionMacro("Type currently not supported");
95+
itkExceptionStringMacro("Type currently not supported");
9696
}
9797
}
9898

@@ -107,7 +107,7 @@ VTKImageImport<TOutputImage>::PropagateRequestedRegion(DataObject * outputPtr)
107107

108108
if (!output)
109109
{
110-
itkExceptionMacro("Downcast from DataObject to my Image type failed.");
110+
itkExceptionStringMacro("Downcast from DataObject to my Image type failed.");
111111
}
112112
Superclass::PropagateRequestedRegion(output);
113113
if (m_PropagateUpdateExtentCallback)

Modules/Bridge/VTK/src/itkVTKImageExportBase.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ VTKImageExportBase::PipelineModifiedCallback()
131131

132132
if (!input)
133133
{
134-
itkExceptionMacro("Need to set an input");
134+
itkExceptionStringMacro("Need to set an input");
135135
}
136136

137137
ModifiedTimeType pipelineMTime = input->GetPipelineMTime();
@@ -169,7 +169,7 @@ VTKImageExportBase::UpdateDataCallback()
169169

170170
if (!input)
171171
{
172-
itkExceptionMacro("Need to set an input");
172+
itkExceptionStringMacro("Need to set an input");
173173
}
174174

175175
// Notify start event observers

Modules/Core/Common/include/itkExtractImageFilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class ITK_TEMPLATE_EXPORT ExtractImageFilter : public InPlaceImageFilter<TInputI
202202
break;
203203
case DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOUNKOWN:
204204
default:
205-
itkExceptionMacro("Invalid Strategy Chosen for itk::ExtractImageFilter");
205+
itkExceptionStringMacro("Invalid Strategy Chosen for itk::ExtractImageFilter");
206206
}
207207

208208
this->m_DirectionCollapseStrategy = choosenStrategy;

Modules/Core/Common/include/itkExtractImageFilter.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ ExtractImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()
196196
{
197197
if (vnl_determinant(outputDirection.GetVnlMatrix()) == 0.0)
198198
{
199-
itkExceptionMacro("Invalid submatrix extracted for collapsed direction.");
199+
itkExceptionStringMacro("Invalid submatrix extracted for collapsed direction.");
200200
}
201201
}
202202
break;

Modules/Core/Common/include/itkFrustumSpatialFunction.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ FrustumSpatialFunction<VDimension, TInput>::Evaluate(const InputType & position)
106106
}
107107
else
108108
{
109-
itkExceptionMacro("Rotation plane not set or set to an unsupported value!");
109+
itkExceptionStringMacro("Rotation plane not set or set to an unsupported value!");
110110
}
111111
}
112112

Modules/Core/Common/include/itkGaussianOperator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ITK_TEMPLATE_EXPORT GaussianOperator : public NeighborhoodOperator<TPixel,
9090
{
9191
if (max_error >= 1 || max_error <= 0)
9292
{
93-
itkExceptionMacro("Maximum Error Must be in the range [ 0.0 , 1.0 ]");
93+
itkExceptionStringMacro("Maximum Error Must be in the range [ 0.0 , 1.0 ]");
9494
}
9595

9696
m_MaximumError = max_error;

Modules/Core/Common/include/itkImageDuplicator.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ImageDuplicator<TInputImage>::Update()
2929
{
3030
if (!m_InputImage)
3131
{
32-
itkExceptionMacro("Input image has not been connected");
32+
itkExceptionStringMacro("Input image has not been connected");
3333
}
3434

3535
// Update only if the input image has been modified

Modules/Core/Common/include/itkImageSource.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ ImageSource<TOutputImage>::GraftOutput(const DataObjectIdentifierType & key, Dat
107107
{
108108
if (!graft)
109109
{
110-
itkExceptionMacro("Requested to graft output that is a nullptr pointer");
110+
itkExceptionStringMacro("Requested to graft output that is a nullptr pointer");
111111
}
112112

113113
// we use the process object method since all out output may not be

Modules/Core/Common/include/itkPointSetBase.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ PointSetBase<TPointsContainer>::SetPoints(PointsVectorContainer * points)
6666
itkDebugMacro("setting Points container to " << points);
6767
if (points->Size() % PointDimension != 0)
6868
{
69-
itkExceptionMacro("Number of entries in given 1d array incompatible with the point dimension");
69+
itkExceptionStringMacro("Number of entries in given 1d array incompatible with the point dimension");
7070
}
7171

7272
// Note: this cast is unsafe. It may lead to undefined behavior.
@@ -87,7 +87,7 @@ PointSetBase<TPointsContainer>::SetPointsByCoordinates(const std::vector<Coordin
8787

8888
if (numberOfCoordinates % PointDimension != 0)
8989
{
90-
itkExceptionMacro("Number of specified coordinates incompatible with the point dimension");
90+
itkExceptionStringMacro("Number of specified coordinates incompatible with the point dimension");
9191
}
9292

9393
const size_t numberOfPoints = numberOfCoordinates / PointDimension;
@@ -192,7 +192,7 @@ PointSetBase<TPointsContainer>::GetPoint(PointIdentifier ptId) const -> PointTyp
192192
*/
193193
if (!m_PointsContainer)
194194
{
195-
itkExceptionMacro("Point container doesn't exist.");
195+
itkExceptionStringMacro("Point container doesn't exist.");
196196
}
197197

198198
/**

0 commit comments

Comments
 (0)