Skip to content

Commit

Permalink
perf: Faster CBaseStream::ReduceTimePoints
Browse files Browse the repository at this point in the history
Increase finalizing speed if Save Time Hint applied.
  • Loading branch information
vasylskorych committed Feb 16, 2024
1 parent 6e94ca3 commit 0eb14e2
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions ModelsAPI/BaseStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,14 @@ void CBaseStream::ReduceTimePoints(double _timeBeg, double _timeEnd, double _ste
if (timePoints.size() <= 3) return;
timePoints.pop_back();

size_t iTime1 = 0;
size_t iTime2 = 1;
while (iTime1 < timePoints.size() && iTime2 < timePoints.size())
auto itBeg = timePoints.begin();
const auto itEnd = timePoints.end();
while (itBeg != itEnd)
{
if (std::fabs(timePoints[iTime1] - timePoints[iTime2]) < _step)
{
RemoveTimePoint(timePoints[iTime2]);
VectorDelete(timePoints, iTime2);
}
else
{
iTime1++;
iTime2++;
}
auto it = std::find_if(itBeg, itEnd, [&](double t) { return std::fabs(*itBeg - t) >= _step; });
if (std::distance(itBeg, it) > 2)
RemoveTimePoints(*itBeg, *it, false);
itBeg = it;
}
}

Expand Down

0 comments on commit 0eb14e2

Please sign in to comment.