Commit 179b5775 authored by Volker Krause's avatar Volker Krause Committed by Torsten Rahn
Browse files

Don't call the non-const variant of GeoDataMultiGeometry::at when unneeded

This fixes expensive detaches in a number of places.
parent 37131c4a
......@@ -108,7 +108,7 @@ const GeoDataLatLonAltBox &GeoDataBuilding::latLonAltBox() const
{
// @TODO: This is temporary, for only when we have just one child
Q_ASSERT(d->m_multiGeometry.size() == 1);
return d->m_multiGeometry.at(0).latLonAltBox();
return static_cast<const GeoDataMultiGeometry>(d->m_multiGeometry).at(0).latLonAltBox();
}
QString GeoDataBuilding::name() const
......
......@@ -48,9 +48,9 @@ void OsmObjectManager::initializeOsmData( GeoDataPlacemark* placemark )
const auto building = geodata_cast<GeoDataBuilding>(placemark->geometry());
GeoDataLinearRing* lineString;
const GeoDataLinearRing* lineString;
if (building) {
lineString = geodata_cast<GeoDataLinearRing>(&building->multiGeometry()->at(0));
lineString = geodata_cast<GeoDataLinearRing>(&static_cast<const GeoDataMultiGeometry*>(building->multiGeometry())->at(0));
} else {
lineString = geodata_cast<GeoDataLinearRing>(placemark->geometry());
}
......@@ -63,9 +63,9 @@ void OsmObjectManager::initializeOsmData( GeoDataPlacemark* placemark )
}
}
GeoDataPolygon* polygon;
const GeoDataPolygon* polygon;
if (building) {
polygon = geodata_cast<GeoDataPolygon>(&building->multiGeometry()->at(0));
polygon = geodata_cast<GeoDataPolygon>(&static_cast<const GeoDataMultiGeometry*>(building->multiGeometry())->at(0));
} else {
polygon = geodata_cast<GeoDataPolygon>(placemark->geometry());
}
......
......@@ -77,9 +77,9 @@ GeoDataDocument *VectorClipper::clipTo(const GeoDataLatLonBox &tileBoundary, int
} else if (geodata_cast<GeoDataLinearRing>(geometry)) {
clipString<GeoDataLinearRing>(placemark, clip, minArea, tile, osmIds);
} else if (const auto building = geodata_cast<GeoDataBuilding>(geometry)) {
if (geodata_cast<GeoDataPolygon>(&building->multiGeometry()->at(0))) {
if (geodata_cast<GeoDataPolygon>(&static_cast<const GeoDataMultiGeometry*>(building->multiGeometry())->at(0))) {
clipPolygon(placemark, clip, minArea, tile, osmIds);
} else if (geodata_cast<GeoDataLinearRing>(&building->multiGeometry()->at(0))) {
} else if (geodata_cast<GeoDataLinearRing>(&static_cast<const GeoDataMultiGeometry*>(building->multiGeometry())->at(0))) {
clipString<GeoDataLinearRing>(placemark, clip, minArea, tile, osmIds);
}
} else {
......@@ -233,7 +233,7 @@ void VectorClipper::clipPolygon(const GeoDataPlacemark *placemark, const Clipper
bool isBuilding = false;
GeoDataPolygon* polygon;
if (const auto building = geodata_cast<GeoDataBuilding>(placemark->geometry())) {
polygon = geodata_cast<GeoDataPolygon>(&building->multiGeometry()->at(0));
polygon = geodata_cast<GeoDataPolygon>(&static_cast<GeoDataMultiGeometry*>(building->multiGeometry())->at(0));
isBuilding = true;
} else {
GeoDataPlacemark* copyPlacemark = new GeoDataPlacemark(*placemark);
......
......@@ -53,9 +53,9 @@ private:
GeoDataDocument* document, QSet<qint64> &osmIds)
{
bool isBuilding = false;
T* ring;
const T* ring;
if (const auto building = geodata_cast<GeoDataBuilding>(placemark->geometry())) {
ring = geodata_cast<T>(&building->multiGeometry()->at(0));
ring = geodata_cast<T>(&static_cast<const GeoDataMultiGeometry*>(building->multiGeometry())->at(0));
isBuilding = true;
} else {
GeoDataPlacemark* copyPlacemark = new GeoDataPlacemark(*placemark);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment