tiled-0001: mapdocument.cpp sortObjects/sortLayers/moveLayersUp/Down/duplicate QList.contains() inside iteration over all map layers/objects = O(N*S) Fix: QSet O(1) lookup. MEDIUM severity. 24x speedup at N=2000,S=1000. tiled-0002: mapobjectmodel.cpp classChanged QList.contains(tile) inside nested loop over all map objects = O(O*T) Fix: QSet O(1) lookup. MEDIUM severity. 14x speedup at O=2000,T=500. tiled-0003: editpolygontool.cpp updateHandles QList.contains() inside QHash iteration = O(H*S) Fix: QSet O(1) lookup. MEDIUM severity. 13x speedup at H=1000,S=500. 3/3 PASS. MOAD-0002/0003/0004/0005 CLEAN.
30 lines
1.2 KiB
Diff
30 lines
1.2 KiB
Diff
# UNDF: UNDF-2026-000000951
|
|
--- a/src/tiled/editpolygontool.cpp
|
|
+++ b/src/tiled/editpolygontool.cpp
|
|
@@ -383,6 +383,8 @@ void EditPolygonTool::updateHandles()
|
|
{
|
|
const QList<MapObject*> &selection = mapDocument()->selectedObjects();
|
|
|
|
+ const QSet<MapObject*> selectionSet(selection.begin(), selection.end());
|
|
+
|
|
auto deleteHandle = [this](PointHandle *handle) {
|
|
if (mHoveredHandle == handle)
|
|
mHoveredHandle = nullptr;
|
|
@@ -399,13 +401,13 @@ void EditPolygonTool::updateHandles()
|
|
QMutableHashIterator<MapObject*, QList<PointHandle*> > i(mHandles);
|
|
while (i.hasNext()) {
|
|
i.next();
|
|
- if (!selection.contains(i.key())) {
|
|
+ if (!selectionSet.contains(i.key())) {
|
|
for (PointHandle *handle : std::as_const(i.value()))
|
|
deleteHandle(handle);
|
|
|
|
i.remove();
|
|
}
|
|
}
|
|
- if (mHoveredSegment && !selection.contains(mHoveredSegment.object))
|
|
+ if (mHoveredSegment && !selectionSet.contains(mHoveredSegment.object))
|
|
mHoveredSegment.clear();
|
|
- if (mClickedSegment && !selection.contains(mClickedSegment.object))
|
|
+ if (mClickedSegment && !selectionSet.contains(mClickedSegment.object))
|
|
mClickedSegment.clear();
|