qdoc: don't hold Location in QLists, don't even copy it

Location is a self-referential type that is very expensive to copy.
So don't.

Instead, just remember the iterator, and use value()->location()
(which returns a reference, so doesn't copy).

Change-Id: I9a2b72b05b8051e793cf67179a0195f2f3551a10
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Martin Smith <martin.smith@digia.com>
This commit is contained in:
Marc Mutz 2015-06-20 17:28:12 +02:00
parent 792f68adea
commit 831a7e06c0

View File

@ -1142,18 +1142,15 @@ const DocumentNode* Tree::findDocumentNodeByTitle(const QString& title) const
DocumentNodeMultiMap::const_iterator j = i; DocumentNodeMultiMap::const_iterator j = i;
++j; ++j;
if (j != docNodesByTitle_.constEnd() && j.key() == i.key()) { if (j != docNodesByTitle_.constEnd() && j.key() == i.key()) {
QList<Location> internalLocations;
while (j != docNodesByTitle_.constEnd()) { while (j != docNodesByTitle_.constEnd()) {
if (j.key() == i.key() && j.value()->url().isEmpty()) { if (j.key() == i.key() && j.value()->url().isEmpty()) {
internalLocations.append(j.value()->location());
break; // Just report one duplicate for now. break; // Just report one duplicate for now.
} }
++j; ++j;
} }
if (internalLocations.size() > 0) { if (j != docNodesByTitle_.cend()) {
i.value()->location().warning("This page title exists in more than one file: " + title); i.value()->location().warning("This page title exists in more than one file: " + title);
foreach (const Location &location, internalLocations) j.value()->location().warning("[It also exists here]");
location.warning("[It also exists here]");
} }
} }
return i.value(); return i.value();