mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
(JBR-8965) PluginPathManager: work around performance degradation
java.io rerouted through java.nio causes performance degradations sometimes, because it relies on throwing and catching exceptions e.g. for checking File::isDirectory. This commit reduces the corresponding costs in the PluginPathManager somewhat by not triggering the same slow IO operations for multiple times. GitOrigin-RevId: fe4e70ea46eff352ee12f5b361c59e96b36b8cc9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ee1a22a61f
commit
dc503d46fb
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.application;
|
||||
|
||||
import com.intellij.ide.plugins.PluginManagerCoreKt;
|
||||
@@ -12,6 +12,8 @@ import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public final class PluginPathManager {
|
||||
private PluginPathManager() {
|
||||
@@ -59,18 +61,20 @@ public final class PluginPathManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static ConcurrentMap<String, File> ourPluginHomes = new ConcurrentHashMap<>();
|
||||
|
||||
public static File getPluginHome(@NonNls String pluginName) {
|
||||
File subRepo = findSubRepo(pluginName);
|
||||
if (subRepo != null) {
|
||||
return subRepo;
|
||||
}
|
||||
return new File(PathManager.getHomePath(), "plugins/" + pluginName);
|
||||
File subRepo = ourPluginHomes.computeIfAbsent(pluginName, k -> {
|
||||
File repo = findSubRepo(k);
|
||||
return repo != null ? repo : new File(PathManager.getHomePath(), "plugins/" + k);
|
||||
});
|
||||
return subRepo;
|
||||
}
|
||||
|
||||
private static File findSubRepo(String pluginName) {
|
||||
for (File subRepo : SubRepoHolder.subRepos) {
|
||||
File candidate = new File(subRepo, pluginName);
|
||||
if (candidate.isDirectory()) {
|
||||
if (candidate.exists() && candidate.isDirectory()) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user