Skip to content

Commit

Permalink
Use map find instead of at (#2721) (#2722)
Browse files Browse the repository at this point in the history
Fixes performance issues on Windows caused by exceptions.
  • Loading branch information
abellgithub committed Sep 6, 2019
1 parent d1eaa6d commit b31fe97
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
9 changes: 5 additions & 4 deletions plugins/e57/io/E57Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ void E57Reader::ChunkReader::setPoint
{
double value;
// Rescale the value if needed so that if fits Pdal expectations
try
std::pair<double, double> minmax;
if (m_scan->getLimits(pdalDimension, minmax))
{
auto minmax = m_scan->getLimits(pdalDimension);
value = pdal::e57plugin::rescaleE57ToPdalValue(keyValue.first,keyValue.second[index],minmax);
value = e57plugin::rescaleE57ToPdalValue(keyValue.first,
keyValue.second[index], minmax);
}
catch (std::out_of_range &e)
else
{
value = keyValue.second[index];
}
Expand Down
11 changes: 9 additions & 2 deletions plugins/e57/io/Scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,16 @@ e57::CompressedVectorNode Scan::getPoints() const
return *m_rawPoints;
}

std::pair<double,double> Scan::getLimits(pdal::Dimension::Id pdalId) const
bool Scan::getLimits(pdal::Dimension::Id pdalId, std::pair<double, double>& minMax) const
{
return m_valueBounds.at(pdalId);
auto itMinMax = m_valueBounds.find(pdalId);
if (itMinMax != m_valueBounds.end())
{
minMax = itMinMax->second;
return true;
}

return false;
}

bool Scan::hasPose() const
Expand Down
2 changes: 1 addition & 1 deletion plugins/e57/io/Scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PDAL_DLL Scan

e57::CompressedVectorNode getPoints() const;

std::pair<double,double> getLimits(pdal::Dimension::Id pdalId) const;
bool getLimits(pdal::Dimension::Id pdalId, std::pair<double, double>& minMax) const;

bool hasPose() const;
void transformPoint(pdal::PointRef pt) const;
Expand Down

0 comments on commit b31fe97

Please sign in to comment.