forked from qt-creator/qt-creator
Git: Reduce PATH searches for executable
This reduces executions in BranchModel::updateUpstreamStatus (which is called for each local branch with a tracking branch) from 3s to ~700ms on Windows. Change-Id: I92651ba8f37987bef49a80b46963964ae8cacb3c Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
728e73ea9d
commit
c2cfe596b9
@@ -116,6 +116,9 @@ GitSettings::GitSettings()
|
|||||||
refLogShowDate.setSettingsKey("RefLogShowDate");
|
refLogShowDate.setSettingsKey("RefLogShowDate");
|
||||||
|
|
||||||
timeout.setDefaultValue(Utils::HostOsInfo::isWindowsHost() ? 60 : 30);
|
timeout.setDefaultValue(Utils::HostOsInfo::isWindowsHost() ? 60 : 30);
|
||||||
|
|
||||||
|
connect(&binaryPath, &StringAspect::valueChanged, this, [this] { tryResolve = true; });
|
||||||
|
connect(&path, &StringAspect::valueChanged, this, [this] { tryResolve = true; });
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const
|
FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const
|
||||||
@@ -126,18 +129,21 @@ FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const
|
|||||||
if (errorMessage)
|
if (errorMessage)
|
||||||
errorMessage->clear();
|
errorMessage->clear();
|
||||||
|
|
||||||
FilePath binPath = binaryPath.filePath();
|
if (tryResolve) {
|
||||||
if (!binPath.isAbsolutePath())
|
resolvedBinPath = binaryPath.filePath();
|
||||||
binPath = binPath.searchInPath({path.filePath()}, FilePath::PrependToPath);
|
if (!resolvedBinPath.isAbsolutePath())
|
||||||
|
resolvedBinPath = resolvedBinPath.searchInPath({path.filePath()}, FilePath::PrependToPath);
|
||||||
|
tryResolve = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (binPath.isEmpty()) {
|
if (resolvedBinPath.isEmpty()) {
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = false;
|
*ok = false;
|
||||||
if (errorMessage)
|
if (errorMessage)
|
||||||
*errorMessage = Tr::tr("The binary \"%1\" could not be located in the path \"%2\"")
|
*errorMessage = Tr::tr("The binary \"%1\" could not be located in the path \"%2\"")
|
||||||
.arg(binaryPath.value(), path.value());
|
.arg(binaryPath.value(), path.value());
|
||||||
}
|
}
|
||||||
return binPath;
|
return resolvedBinPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GitSettingsPage
|
// GitSettingsPage
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ public:
|
|||||||
Utils::BoolAspect refLogShowDate;
|
Utils::BoolAspect refLogShowDate;
|
||||||
Utils::BoolAspect instantBlame;
|
Utils::BoolAspect instantBlame;
|
||||||
|
|
||||||
|
mutable Utils::FilePath resolvedBinPath;
|
||||||
|
mutable bool tryResolve = true;
|
||||||
|
|
||||||
Utils::FilePath gitExecutable(bool *ok = nullptr, QString *errorMessage = nullptr) const;
|
Utils::FilePath gitExecutable(bool *ok = nullptr, QString *errorMessage = nullptr) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user