Utils: allow specifying the requested extension for searchInPath

Reducing the expected executable extensions can improve the performance
for search in path on Window. Especially if PATHEXT and PATH has a lot
of entries, since we collect file attributes for PATHEXT entry count
times PATH entry count file paths. Use this optimization in the android
toolchain to search for java.exe on windows.

Change-Id: I2c2865d685c2de0c03a0fa1fbe7e8afd283174da
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
David Schulz
2023-09-21 08:59:15 +02:00
parent fbbb78ee7e
commit 7adee4da24
3 changed files with 7 additions and 4 deletions

View File

@@ -94,7 +94,8 @@ void AndroidToolChain::addToEnvironment(Environment &env) const
if (javaHome.exists()) {
env.set(Constants::JAVA_HOME_ENV_VAR, javaHome.toUserOutput());
const FilePath javaBin = javaHome.pathAppended("bin");
const FilePath currentJavaFilePath = env.searchInPath("java");
const FilePath currentJavaFilePath
= env.searchInPath("java", {}, {}, FilePath::WithExeSuffix);
if (!currentJavaFilePath.isChildOf(javaBin))
env.prependOrSetPath(javaBin);
}