Commit 5c0b21d7 authored by Tobias Hunger's avatar Tobias Hunger

Environment: Modernize a bit

Change-Id: I84afdfd8c8b5066c1b50192bfd9df2296a38fa23
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent 5bd28870
...@@ -113,14 +113,11 @@ QList<EnvironmentItem> EnvironmentItem::fromStringList(const QStringList &list) ...@@ -113,14 +113,11 @@ QList<EnvironmentItem> EnvironmentItem::fromStringList(const QStringList &list)
QStringList EnvironmentItem::toStringList(const QList<EnvironmentItem> &list) QStringList EnvironmentItem::toStringList(const QList<EnvironmentItem> &list)
{ {
QStringList result; return Utils::transform(list, [](const EnvironmentItem &item) {
for (const EnvironmentItem &item : list) {
if (item.operation == EnvironmentItem::Unset) if (item.operation == EnvironmentItem::Unset)
result << QString(item.name); return QString(item.name);
else return QString(item.name + '=' + item.value);
result << QString(item.name + '=' + item.value); });
}
return result;
} }
static QString expand(const Environment *e, QString value) static QString expand(const Environment *e, QString value)
...@@ -242,19 +239,15 @@ Environment::Environment(const QStringList &env, OsType osType) : m_osType(osTyp ...@@ -242,19 +239,15 @@ Environment::Environment(const QStringList &env, OsType osType) : m_osType(osTyp
QStringList Environment::toStringList() const QStringList Environment::toStringList() const
{ {
QStringList result; QStringList result;
const QMap<QString, QString>::const_iterator end = m_values.constEnd(); for (auto it = m_values.constBegin(); it != m_values.constEnd(); ++it)
for (QMap<QString, QString>::const_iterator it = m_values.constBegin(); it != end; ++it) { result.append(it.key() + '=' + it.value());
const QString entry = it.key() + '=' + it.value();
result.append(entry);
}
return result; return result;
} }
QProcessEnvironment Environment::toProcessEnvironment() const QProcessEnvironment Environment::toProcessEnvironment() const
{ {
QProcessEnvironment result; QProcessEnvironment result;
const QMap<QString, QString>::const_iterator end = m_values.constEnd(); for (auto it = m_values.constBegin(); it != m_values.constEnd(); ++it)
for (QMap<QString, QString>::const_iterator it = m_values.constBegin(); it != end; ++it)
result.insert(it.key(), it.value()); result.insert(it.key(), it.value());
return result; return result;
} }
......
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