Skip to content

Commit 21b08ab

Browse files
hjmjohnsondzenanz
authored andcommitted
PERF: Prefer default initialization for std::string
Return {} may be the fastest, because it just calls the default-constructor of std::string. (return { "" } and return "" may be slightly slower because they convert a literal string to an std::string. This probably does not have a substantive impact on the current uses, but implementing to keep the style consistent.
1 parent e9af5c5 commit 21b08ab

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

Modules/Core/Common/src/itkBuildInformation.cxx.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ BuildInformation::GetValue(const MapKeyType & key)
8787
{
8888
return it->second.m_Value;
8989
}
90-
return {""};
90+
return {};;
9191
}
9292

9393
const BuildInformation::MapValueDescriptionType
@@ -100,7 +100,7 @@ BuildInformation::GetDescription(const MapKeyType & key)
100100
{
101101
return it->second.m_Description;
102102
}
103-
return {""};
103+
return {};;
104104
}
105105

106106
const std::vector< BuildInformation::MapKeyType >

Modules/Core/SpatialObjects/include/itkDTITubeSpatialObjectPoint.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ DTITubeSpatialObjectPoint<TPointDimension>::TranslateEnumToChar(DTITubeSpatialOb
6464
// Just fall through.
6565
break;
6666
}
67-
return { "" };
67+
return {};
6868
}
6969

7070
template <unsigned int TPointDimension>

Modules/IO/SpatialObjects/src/itkPolygonGroupSpatialObjectXMLFile.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class NumericTraits<std::string>
165165
static std::string
166166
ZeroValue()
167167
{
168-
return { "" };
168+
return {};
169169
}
170170
};
171171

Modules/Numerics/Optimizers/src/itkLBFGSOptimizer.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,6 @@ LBFGSOptimizer::GetStopConditionDescription() const
315315
return m_StopConditionDescription.str();
316316
}
317317

318-
return { "" };
318+
return {};
319319
}
320320
} // end namespace itk

Modules/Numerics/Optimizersv4/src/itkLBFGSOptimizerv4Base.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ LBFGSOptimizerBasev4<TInternalVnlOptimizerType>::GetStopConditionDescription() c
213213
return m_StopConditionDescription.str();
214214
}
215215

216-
return { "" };
216+
return {};
217217
}
218218

219219
template class ITKOptimizersv4_EXPORT LBFGSOptimizerBasev4<vnl_lbfgs>;

0 commit comments

Comments
 (0)