summaryrefslogtreecommitdiffstats
path: root/src/svg/qsvghandler.cpp
diff options
context:
space:
mode:
authorAriya Hidayat <ariya.hidayat@nokia.com>2009-08-31 13:28:30 (GMT)
committerAriya Hidayat <ariya.hidayat@nokia.com>2009-08-31 13:36:44 (GMT)
commita8c5ded0de4b466b348080bfdef3107af39ed508 (patch)
tree9cff830569adb037e702b18d04d5892621c61a73 /src/svg/qsvghandler.cpp
parent8a3f912f7cbe6d019f847ed1eb67efb1a29a5851 (diff)
downloadQt-a8c5ded0de4b466b348080bfdef3107af39ed508.zip
Qt-a8c5ded0de4b466b348080bfdef3107af39ed508.tar.gz
Qt-a8c5ded0de4b466b348080bfdef3107af39ed508.tar.bz2
Speed-up parseCoreNode() for SVG parsing.
Instead of doing an attribute look-up via QXmlAttributes::value(), we just iterate by ourselves. Thus, we need to carry out the iteration and comparison only once, instead of every call to the said value(). Reviewed-by: Kim
Diffstat (limited to 'src/svg/qsvghandler.cpp')
-rw-r--r--src/svg/qsvghandler.cpp52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index 344e2b1..2fec215 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -1819,27 +1819,49 @@ static inline QStringList stringToList(const QString &str)
static bool parseCoreNode(QSvgNode *node,
const QXmlStreamAttributes &attributes)
{
- QString featuresStr = attributes.value(QLatin1String("requiredFeatures")).toString();
- QString extensionsStr = attributes.value(QLatin1String("requiredExtensions")).toString();
- QString languagesStr = attributes.value(QLatin1String("systemLanguage")).toString();
- QString formatsStr = attributes.value(QLatin1String("requiredFormats")).toString();
- QString fontsStr = attributes.value(QLatin1String("requiredFonts")).toString();
- QString nodeIdStr = someId(attributes);
- QString xmlClassStr = attributes.value(QLatin1String("class")).toString();
-
-
- QStringList features = stringToList(featuresStr);
- QStringList extensions = stringToList(extensionsStr);
- QStringList languages = stringToList(languagesStr);
- QStringList formats = stringToList(formatsStr);
- QStringList fonts = stringToList(fontsStr);
+ QStringList features;
+ QStringList extensions;
+ QStringList languages;
+ QStringList formats;
+ QStringList fonts;
+ QString xmlClassStr;
+
+ for (int i = 0; i < attributes.count(); ++i) {
+ const QXmlStreamAttribute &attribute = attributes.at(i);
+ QStringRef name = attribute.qualifiedName();
+ if (name.isEmpty())
+ continue;
+ QStringRef value = attribute.value();
+ switch (name.at(0).unicode()) {
+ case 'c':
+ if (name == QLatin1String("class"))
+ xmlClassStr = value.toString();
+ break;
+ case 'r':
+ if (name == QLatin1String("requiredFeatures"))
+ features = stringToList(value.toString());
+ else if (name == QLatin1String("requiredExtensions"))
+ extensions = stringToList(value.toString());
+ else if (name == QLatin1String("requiredFormats"))
+ formats = stringToList(value.toString());
+ else if (name == QLatin1String("requiredFonts"))
+ fonts = stringToList(value.toString());
+ break;
+ case 's':
+ if (name == QLatin1String("systemLanguage"))
+ languages = stringToList(value.toString());
+ break;
+ default:
+ break;
+ }
+ }
node->setRequiredFeatures(features);
node->setRequiredExtensions(extensions);
node->setRequiredLanguages(languages);
node->setRequiredFormats(formats);
node->setRequiredFonts(fonts);
- node->setNodeId(nodeIdStr);
+ node->setNodeId(someId(attributes));
node->setXmlClass(xmlClassStr);
return true;