scene/workspacescene: don't iterate through all child items twice
Instead, use an iterator for the second loop to pick up where the first loop stopped
This commit is contained in:
parent
60e3964322
commit
b8b900891b
1 changed files with 5 additions and 5 deletions
|
@ -154,7 +154,9 @@ Item *WorkspaceScene::overlayItem() const
|
|||
static bool addCandidates(SurfaceItem *item, QList<SurfaceItem *> &candidates, ssize_t maxCount, QRegion &occluded)
|
||||
{
|
||||
const QList<Item *> children = item->sortedChildItems();
|
||||
for (const auto &child : children | std::views::reverse) {
|
||||
auto it = children.rbegin();
|
||||
for (; it != children.rend(); it++) {
|
||||
Item *const child = *it;
|
||||
if (child->z() < 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -169,10 +171,8 @@ static bool addCandidates(SurfaceItem *item, QList<SurfaceItem *> &candidates, s
|
|||
}
|
||||
candidates.push_back(item);
|
||||
occluded += item->mapToScene(item->opaque());
|
||||
for (const auto &child : children | std::views::reverse) {
|
||||
if (child->z() >= 0) {
|
||||
continue;
|
||||
}
|
||||
for (; it != children.rend(); it++) {
|
||||
Item *const child = *it;
|
||||
if (child->isVisible() && !occluded.contains(child->mapToScene(child->boundingRect()).toAlignedRect())) {
|
||||
if (!addCandidates(static_cast<SurfaceItem *>(child), candidates, maxCount, occluded)) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue