diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-09-04 16:55:29 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-09-20 18:24:49 +0000 |
commit | 21cc71ced3565585f7a2f94875ed845355ab2064 (patch) | |
tree | fc9c632572e6f69d3753bc4a2658cec3e5cc7bff /src/xmlpatterns/expr/qexpressionfactory.cpp | |
parent | b1b57225dbc8733935697e1895631969e9a95376 (diff) | |
download | qtxmlpatterns-21cc71ced3565585f7a2f94875ed845355ab2064.tar.gz |
Eradicate Java-style loops (I): QHashIterator -> STL-style
Java-style iterators are slower than STL-style ones, so
they should not be used in library code.
Replaced them with STL iterator loops.
In one case, a QMutableHashIterator actually needn't be
mutable, so ported to const_iterator, like all others.
Change-Id: Ib7fd1fa5fca2df2c288a61925ee68a5df11caf62
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/xmlpatterns/expr/qexpressionfactory.cpp')
-rw-r--r-- | src/xmlpatterns/expr/qexpressionfactory.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/xmlpatterns/expr/qexpressionfactory.cpp b/src/xmlpatterns/expr/qexpressionfactory.cpp index f205def..b0e43be 100644 --- a/src/xmlpatterns/expr/qexpressionfactory.cpp +++ b/src/xmlpatterns/expr/qexpressionfactory.cpp @@ -279,11 +279,7 @@ Expression::Ptr ExpressionFactory::createExpression(const Tokenizer::Ptr &tokeni { pDebug() << "Have " << info->namedTemplates.count() << "named templates"; - QMutableHashIterator<QXmlName, Template::Ptr> it(info->namedTemplates); - - while(it.hasNext()) - { - it.next(); + for (auto it = info->namedTemplates.cbegin(), end = info->namedTemplates.cend(); it != end; ++it) { processNamedTemplate(it.key(), it.value()->body, TemplateInitial); it.value()->body = it.value()->body->typeCheck(context, CommonSequenceTypes::ZeroOrMoreItems); @@ -298,7 +294,6 @@ Expression::Ptr ExpressionFactory::createExpression(const Tokenizer::Ptr &tokeni /* Type check and compress template rules. */ { - QHashIterator<QXmlName, TemplateMode::Ptr> it(info->templateRules); /* Since a pattern can exist of AxisStep, its typeCheck() stage * requires a focus. In the case that we're invoked with a name but @@ -313,9 +308,7 @@ Expression::Ptr ExpressionFactory::createExpression(const Tokenizer::Ptr &tokeni patternContext = StaticContext::Ptr(new StaticFocusContext(BuiltinTypes::node, context)); /* For each template pattern. */ - while(it.hasNext()) - { - it.next(); + for (auto it = info->templateRules.cbegin(), end = info->templateRules.cend(); it != end; ++it) { const TemplateMode::Ptr &mode = it.value(); const int len = mode->templatePatterns.count(); TemplatePattern::ID currentTemplateID = -1; @@ -387,12 +380,7 @@ Expression::Ptr ExpressionFactory::createExpression(const Tokenizer::Ptr &tokeni Q_ASSERT_X(modeAll, Q_FUNC_INFO, "We should at least have the builtin templates."); - QHashIterator<QXmlName, TemplateMode::Ptr> it(info->templateRules); - - while(it.hasNext()) - { - it.next(); - + for (auto it = info->templateRules.cbegin(), end = info->templateRules.cend(); it != end; ++it) { /* Don't add mode #all to mode #all. */ if(it.key() == nameModeAll) continue; |