aboutsummaryrefslogtreecommitdiff
path: root/src/kconfig_compiler/KConfigXmlParser.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2021-02-23 00:37:11 +0200
committerAhmad Samir <a.samirh78@gmail.com>2021-03-06 01:35:08 +0200
commit9d87348260316af729892c58bc29f159a173abf1 (patch)
treeaf81edda4bf441239f4ccc66dbfb533c5be26a47 /src/kconfig_compiler/KConfigXmlParser.cpp
parentee35bdce8f6b08922b4c9e0c0c838e5f2c4a79ad (diff)
downloadkconfig-9d87348260316af729892c58bc29f159a173abf1.tar.gz
kconfig-9d87348260316af729892c58bc29f159a173abf1.tar.bz2
Minor code optimisation
- Use more range-for loops where appropriate - Use auto instead of the usually-long iterator type names - Use cbegin/cend(), to match the std:: containers, less confusion - Use qDeleteAll instead of a for loop - Make a QRE with a long-ish pattern static NO_CHANGELOG
Diffstat (limited to 'src/kconfig_compiler/KConfigXmlParser.cpp')
-rw-r--r--src/kconfig_compiler/KConfigXmlParser.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp
index 97d61342..7dc1d9f0 100644
--- a/src/kconfig_compiler/KConfigXmlParser.cpp
+++ b/src/kconfig_compiler/KConfigXmlParser.cpp
@@ -27,7 +27,7 @@
static void preProcessDefault(QString &defaultValue,
const QString &name,
const QString &type,
- const CfgEntry::Choices &choices,
+ const CfgEntry::Choices &cfgChoices,
QString &code,
const KConfigParameters &cfg)
{
@@ -51,13 +51,12 @@ static void preProcessDefault(QString &defaultValue,
cpp << " QStringList default" << name << ";\n";
}
const QStringList defaults = defaultValue.split(QLatin1Char(','));
- QStringList::ConstIterator it;
- for (it = defaults.constBegin(); it != defaults.constEnd(); ++it) {
+ for (const auto &val : defaults) {
cpp << " default" << name << ".append( ";
if (type == QLatin1String("UrlList")) {
cpp << "QUrl::fromUserInput(";
}
- cpp << "QString::fromUtf8( \"" << *it << "\" ) ";
+ cpp << "QString::fromUtf8( \"" << val << "\" ) ";
if (type == QLatin1String("UrlList")) {
cpp << ") ";
}
@@ -66,7 +65,7 @@ static void preProcessDefault(QString &defaultValue,
defaultValue = QLatin1String("default") + name;
} else if (type == QLatin1String("Color") && !defaultValue.isEmpty()) {
- const QRegularExpression colorRe(QRegularExpression::anchoredPattern(QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?")));
+ static const QRegularExpression colorRe(QRegularExpression::anchoredPattern(QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?")));
if (colorRe.match(defaultValue).hasMatch()) {
defaultValue = QLatin1String("QColor( ") + defaultValue + QLatin1String(" )");
@@ -75,13 +74,12 @@ static void preProcessDefault(QString &defaultValue,
}
} else if (type == QLatin1String("Enum")) {
- QList<CfgEntry::Choice>::ConstIterator it;
- for (it = choices.choices.constBegin(); it != choices.choices.constEnd(); ++it) {
- if ((*it).name == defaultValue) {
- if (cfg.globalEnums && choices.name().isEmpty()) {
- defaultValue.prepend(choices.prefix);
+ for (const auto &choice : cfgChoices.choices) {
+ if (choice.name == defaultValue) {
+ if (cfg.globalEnums && cfgChoices.name().isEmpty()) {
+ defaultValue.prepend(cfgChoices.prefix);
} else {
- defaultValue.prepend(enumTypeQualifier(name, choices) + choices.prefix);
+ defaultValue.prepend(enumTypeQualifier(name, cfgChoices) + cfgChoices.prefix);
}
break;
}
@@ -96,9 +94,8 @@ static void preProcessDefault(QString &defaultValue,
cpp << " QList<int> default" << name << ";\n";
if (!defaultValue.isEmpty()) {
const QStringList defaults = defaultValue.split(QLatin1Char(','));
- QStringList::ConstIterator it;
- for (it = defaults.constBegin(); it != defaults.constEnd(); ++it) {
- cpp << " default" << name << ".append( " << *it << " );\n";
+ for (const auto &defaultVal : defaults) {
+ cpp << " default" << name << ".append( " << defaultVal << " );\n";
}
}
defaultValue = QLatin1String("default") + name;