Merge pull request #2748 from TheKodeToad/gentoo-java-perf
Improve Java checking speed by using startsWith for gentoo paths
This commit is contained in:
commit
aa206f4c89
@ -403,12 +403,17 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
{
|
{
|
||||||
QList<QString> javas;
|
QList<QString> javas;
|
||||||
javas.append(this->GetDefaultJava()->path);
|
javas.append(this->GetDefaultJava()->path);
|
||||||
auto scanJavaDir = [&](const QString& dirPath) {
|
auto scanJavaDir = [&](
|
||||||
|
const QString& dirPath,
|
||||||
|
const std::function<bool(const QFileInfo&)>& filter = [](const QFileInfo&) { return true; }) {
|
||||||
QDir dir(dirPath);
|
QDir dir(dirPath);
|
||||||
if (!dir.exists())
|
if (!dir.exists())
|
||||||
return;
|
return;
|
||||||
auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
for (auto& entry : entries) {
|
for (auto& entry : entries) {
|
||||||
|
if (!filter(entry))
|
||||||
|
continue;
|
||||||
|
|
||||||
QString prefix;
|
QString prefix;
|
||||||
prefix = entry.canonicalFilePath();
|
prefix = entry.canonicalFilePath();
|
||||||
javas.append(FS::PathCombine(prefix, "jre/bin/java"));
|
javas.append(FS::PathCombine(prefix, "jre/bin/java"));
|
||||||
@ -431,9 +436,13 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
scanJavaDirs("/usr/lib64/jvm");
|
scanJavaDirs("/usr/lib64/jvm");
|
||||||
scanJavaDirs("/usr/lib32/jvm");
|
scanJavaDirs("/usr/lib32/jvm");
|
||||||
// Gentoo's locations for openjdk and openjdk-bin respectively
|
// Gentoo's locations for openjdk and openjdk-bin respectively
|
||||||
scanJavaDir("/usr/lib64");
|
auto gentooFilter = [](const QFileInfo& info) {
|
||||||
scanJavaDir("/usr/lib");
|
QString fileName = info.fileName();
|
||||||
scanJavaDir("/opt");
|
return fileName.startsWith("openjdk-") || fileName.startsWith("openj9-");
|
||||||
|
};
|
||||||
|
scanJavaDir("/usr/lib64", gentooFilter);
|
||||||
|
scanJavaDir("/usr/lib", gentooFilter);
|
||||||
|
scanJavaDir("/opt", gentooFilter);
|
||||||
// javas stored in Prism Launcher's folder
|
// javas stored in Prism Launcher's folder
|
||||||
scanJavaDirs("java");
|
scanJavaDirs("java");
|
||||||
// manually installed JDKs in /opt
|
// manually installed JDKs in /opt
|
||||||
|
Loading…
Reference in New Issue
Block a user