Reorganize getArea() in TreeModelVolumes to silence the warning (<anonymous> may be used uninitialized in this function).

This warning was shown because the previous code was triggering a bug in GCC. More about the bug can be found here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86465.
This commit is contained in:
Lukáš Hejl 2024-01-05 16:28:04 +01:00
parent 7e8f45a302
commit 229946a25c

View File

@ -244,12 +244,16 @@ private:
*/
std::optional<std::reference_wrapper<const Polygons>> getArea(const TreeModelVolumes::RadiusLayerPair &key) const {
std::lock_guard<std::mutex> guard(m_mutex);
if (key.second >= LayerIndex(m_data.size()))
return std::optional<std::reference_wrapper<const Polygons>>{};
const auto &layer = m_data[key.second];
return std::nullopt;
const LayerData &layer = m_data[key.second];
auto it = layer.find(key.first);
return it == layer.end() ?
std::optional<std::reference_wrapper<const Polygons>>{} : std::optional<std::reference_wrapper<const Polygons>>{ it->second };
if (it == layer.end())
return std::nullopt;
return std::optional<std::reference_wrapper<const Polygons>>{it->second};
}
// Get a collision area at a given layer for a radius that is a lower or equial to the key radius.
std::optional<std::pair<coord_t, std::reference_wrapper<const Polygons>>> get_lower_bound_area(const TreeModelVolumes::RadiusLayerPair &key) const {