[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/marble/src/lib/geodata/parser
From: Nikolas Zimmermann <wildfox () kde ! org>
Date: 2008-03-10 2:54:37
Message-ID: 1205117677.869108.16517.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 783936 by wildfox:
Optimize, if debug output is turned off. Don't needlessly push/pop a GeoStackItem, if \
the current element doesn't have non-textual children.
M +18 -9 GeoParser.cpp
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoParser.cpp #783935:783936
@@ -25,7 +25,7 @@
#include "GeoTagHandler.h"
// Set to a value greather than 0, to dump parent node chain while parsing
-#define DUMP_PARENT_STACK 1
+#define DUMP_PARENT_STACK 0
GeoParser::GeoParser(GeoDataGenericSourceType source)
: QXmlStreamReader()
@@ -130,29 +130,38 @@
}
if (isStartElement()) {
+ bool processChildren = true;
GeoStackItem stackItem(qName, 0);
- bool processChildren = true;
-
+
if (const GeoTagHandler* handler = GeoTagHandler::recognizes(qName)) {
stackItem.assignNode(handler->parse(*this));
processChildren = !isEndElement();
}
- m_nodeStack.push(stackItem);
+ // Only add GeoStackItem to the parent chain, if the tag handler for the \
current element + // possibly contains non-textual children. Consider \
following DGML snippet "<name>Test</name>" - + // the DGMLNameTagHandler \
assumes that <name> only contains textual children, and reads the + // \
joined value of all children using readElementText(). This implicates that tags like \
<name> + // don't contain any children that would need to be procesed \
using this parseDocument() function. + if (processChildren) {
+ m_nodeStack.push(stackItem);
#if DUMP_PARENT_STACK > 0
- dumpParentStack(name().toString(), m_nodeStack.size(), false);
+ dumpParentStack(name().toString(), m_nodeStack.size(), false);
#endif
- if (processChildren)
parseDocument();
+ }
+#if DUMP_PARENT_STACK > 0
else {
+ // This is only used for debugging purposes.
+ m_nodeStack.push(stackItem);
+ dumpParentStack(name().toString(), m_nodeStack.size(), false);
+
m_nodeStack.pop();
-
-#if DUMP_PARENT_STACK > 0
dumpParentStack(name().toString(), m_nodeStack.size(), true);
+ }
#endif
- }
}
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic