Commit 85d3cc84 authored by Tobias Hunger's avatar Tobias Hunger

Environment: Don't search the same directory repeatedly

Do not search the same directory repeatedly when looking for binaries.

Change-Id: I97a722cfa689224cb85cdadfd02e283247f96325
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent bbe35e19
......@@ -31,6 +31,7 @@
#include <QDir>
#include <QProcessEnvironment>
#include <QSet>
#include <QCoreApplication>
class SystemEnvironment : public Utils::Environment
......@@ -262,7 +263,11 @@ QString Environment::searchInPath(const QString &executable,
if (fi.isAbsolute())
return exec;
QSet<QString> alreadyChecked;
foreach (const QString &dir, additionalDirs) {
if (alreadyChecked.contains(dir))
continue;
alreadyChecked.insert(dir);
QString tmp = searchInDirectory(execs, dir);
if (!tmp.isEmpty())
return tmp;
......@@ -272,6 +277,9 @@ QString Environment::searchInPath(const QString &executable,
return QString();
foreach (const QString &p, path()) {
if (alreadyChecked.contains(p))
continue;
alreadyChecked.insert(p);
QString tmp = searchInDirectory(execs, QDir::fromNativeSeparators(p));
if (!tmp.isEmpty())
return tmp;
......
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