Skip to content

Commit

Permalink
STYLE: Replace unsafe (T)x and T(x) casts with T{x} in Common/src
Browse files Browse the repository at this point in the history
Replaced C-style casts and function-style casts, `(T)x` and `T(x)`, with
the corresponding but safer braced-initialization syntax, `T{ x }`, in
"Common/src", in cases where `x` is a compile-time constant integer.

Detected by LLVM 14.0.0 clang-tidy option `google-readability-casting`:
https://clang.llvm.org/extra/clang-tidy/checks/google-readability-casting.html

Follow-up to:

pull request #3342
commit 2fa80e8
"STYLE: Avoid old, C-style cast", by Lee Newberg
  • Loading branch information
N-Dekker authored and dzenanz committed Apr 4, 2022
1 parent bd1ba15 commit 4bbccf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Modules/Core/Common/src/itkMultiThreaderBase.cxx
Expand Up @@ -218,7 +218,7 @@ MultiThreaderBase::SetGlobalMaximumNumberOfThreads(ThreadIdType val)

// clamp between 1 and ITK_MAX_THREADS
m_PimplGlobals->m_GlobalMaximumNumberOfThreads =
std::min(m_PimplGlobals->m_GlobalMaximumNumberOfThreads, (ThreadIdType)ITK_MAX_THREADS);
std::min(m_PimplGlobals->m_GlobalMaximumNumberOfThreads, ThreadIdType{ ITK_MAX_THREADS });
m_PimplGlobals->m_GlobalMaximumNumberOfThreads =
std::max(m_PimplGlobals->m_GlobalMaximumNumberOfThreads, NumericTraits<ThreadIdType>::OneValue());

Expand Down Expand Up @@ -351,7 +351,7 @@ MultiThreaderBase::GetGlobalDefaultNumberOfThreads()
}

// limit the number of threads to m_GlobalMaximumNumberOfThreads
threadCount = std::min(threadCount, ThreadIdType(ITK_MAX_THREADS));
threadCount = std::min(threadCount, ThreadIdType{ ITK_MAX_THREADS });

// verify that the default number of threads is larger than zero
threadCount = std::max(threadCount, NumericTraits<ThreadIdType>::OneValue());
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/src/itkSmapsFileParser.cxx
Expand Up @@ -352,15 +352,15 @@ MapData::MemoryLoadType
MapData::GetTotalMemoryUsage()
{
return std::accumulate(
this->m_Records.begin(), this->m_Records.end(), MapData::MemoryLoadType(0), MapRecordPlusor<MemoryLoadType>());
this->m_Records.begin(), this->m_Records.end(), MapData::MemoryLoadType{ 0 }, MapRecordPlusor<MemoryLoadType>());
}

MapData::MemoryLoadType
MapData::GetMemoryUsage(const char * filter, const char * token)
{
return std::accumulate(this->m_Records.begin(),
this->m_Records.end(),
MapData::MemoryLoadType(0),
MapData::MemoryLoadType{ 0 },
MapRecordConditionalPlusor<MemoryLoadType>(filter, token));
}

Expand Down

0 comments on commit 4bbccf2

Please sign in to comment.