Commit d22be027 authored by Pino Toscano's avatar Pino Toscano
Browse files

mapReader: optimize check for single tag

When checking that a tag occurs only once, we currently look for it
from the last of the children of the parent of the tag back to the last
tag. This means iterating back to the first tag in the average case.

Instead, look for the potential next sibling of the tag: while it will
do the same scanning in the average case (i.e. to the last of the
children), there is no need to compare the found tag against the
reference tag, as it will be different for sure.
parent 4e5a32fe
......@@ -198,7 +198,7 @@ QString mapReader::getElementString(const QString &tagName, const QDomElement &p
}
else
{
if (tag == parentTag.lastChildElement(tagName))
if (tag.nextSiblingElement(tagName).isNull())
{
result = tag.text();
}
......@@ -219,7 +219,7 @@ QDomElement mapReader::getElement(const QString &tagName, const QDomElement &par
}
else
{
if (tag != parentTag.lastChildElement(tagName))
if (!tag.nextSiblingElement(tagName).isNull())
{
p_error = i18n("The map description file should have exactly one %1 tag inside %2", tagName, parentTag.tagName());
}
......
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