Skip to content

Commit

Permalink
PERF: Prefer initialization to assignment
Browse files Browse the repository at this point in the history
Initialize the memory to zeros upon allocation.

Avoid initialization followed by assignment to zero.
  • Loading branch information
hjmjohnson committed May 8, 2024
1 parent 408cf0c commit e64032a
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -839,12 +839,8 @@ ParallelSparseFieldLevelSetImageFilter<TInputImage, TOutputImage>::ThreadedAlloc
}
}

// Local histogram for every thread (used during Iterate() )
m_Data[ThreadId].m_ZHistogram = new int[m_ZSize];
for (unsigned int i = 0; i < m_ZSize; ++i)
{
m_Data[ThreadId].m_ZHistogram[i] = 0;
}
// Local histogram for every thread (used during Iterate()), initialized to zeros.
m_Data[ThreadId].m_ZHistogram = new int[m_ZSize]();

// Every thread must have its own copy of the GlobalData struct.
m_Data[ThreadId].globalData = this->GetDifferenceFunction()->GetGlobalDataPointer();
Expand Down

0 comments on commit e64032a

Please sign in to comment.