Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Unified Diff: pkg/analysis_server/lib/src/plugin/plugin_locator.dart

Issue 2754473005: Improve performance of PluginLocator by caching results (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/plugin/plugin_locator.dart
diff --git a/pkg/analysis_server/lib/src/plugin/plugin_locator.dart b/pkg/analysis_server/lib/src/plugin/plugin_locator.dart
index 968ee5384011d96ed66c33dae242ae9a7b6f4b88..85e3527fe83177a580d7e6240fbc1e41d6108ed0 100644
--- a/pkg/analysis_server/lib/src/plugin/plugin_locator.dart
+++ b/pkg/analysis_server/lib/src/plugin/plugin_locator.dart
@@ -37,6 +37,8 @@ class PluginLocator {
*/
final ResourceProvider resourceProvider;
+ final Map<String, String> pluginMap = <String, String>{};
+
/**
* Initialize a newly created plugin locator to use the given
* [resourceProvider] to access the file system.
@@ -56,6 +58,13 @@ class PluginLocator {
* returning it.
*/
String findPlugin(String packageRoot) {
+ return pluginMap.putIfAbsent(packageRoot, () => _findPlugin(packageRoot));
+ }
+
+ /**
+ * The implementation of [findPlugin].
+ */
+ String _findPlugin(String packageRoot) {
Folder packageFolder = resourceProvider.getFolder(packageRoot);
File pubspecFile = packageFolder.getChildAssumingFile(pubspecFileName);
if (pubspecFile.exists) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698