diff --git a/uppsrc/ide/Core/Core.h b/uppsrc/ide/Core/Core.h index 3b61ccfc8..6627abdab 100644 --- a/uppsrc/ide/Core/Core.h +++ b/uppsrc/ide/Core/Core.h @@ -162,6 +162,8 @@ void SetVar(const String& var, const String& value); String GetAnyFileName(const char *path); String GetAnyFileTitle(const char *path); String CatAnyPath(String path, const char *more); + +void InvalidatePackageCache(); String PackagePath(const String& name); String SourcePath(const String& package, const String& name); inline diff --git a/uppsrc/ide/Core/Workspace.cpp b/uppsrc/ide/Core/Workspace.cpp index c56b0724d..a0fafa243 100644 --- a/uppsrc/ide/Core/Workspace.cpp +++ b/uppsrc/ide/Core/Workspace.cpp @@ -173,7 +173,15 @@ bool IsFolder(const String& path) return ff && ff.IsDirectory(); } -String PackagePath(const String& name) { +VectorMap package_cache; + +void InvalidatePackageCache() +{ + package_cache.Clear(); +} + +String PackagePath0(const String& name) +{ String uppfile = NativePath(name); if(IsFullPath(uppfile)) return NormalizePath(uppfile); Vector d = GetUppDirs(); @@ -187,6 +195,17 @@ String PackagePath(const String& name) { GetFileName(uppfile)) + ".upp") : ""; } +String PackagePath(const String& name) +{ + int q = package_cache.Find(name); + if(q < 0) { + String h = PackagePath0(name); + package_cache.Add(name, h); + return h; + } + return package_cache[q]; +} + String SourcePath(const String& package, const String& file) { if(IsFullPath(file)) return NativePath(file); return NormalizePath(AppendFileName(GetFileFolder(PackagePath(package)), file)); diff --git a/uppsrc/ide/UppDlg.cpp b/uppsrc/ide/UppDlg.cpp index 454fcb29c..44a0a9790 100644 --- a/uppsrc/ide/UppDlg.cpp +++ b/uppsrc/ide/UppDlg.cpp @@ -576,6 +576,7 @@ PackageEditor::PackageEditor() } void EditPackages(const char *main, const char *startwith, String& cfg) { + InvalidatePackageCache(); PackageEditor pe; pe.Sizeable(); StringStream in(cfg); diff --git a/uppsrc/ide/UppWspc.cpp b/uppsrc/ide/UppWspc.cpp index 1b8fff8c9..a9d48b43c 100644 --- a/uppsrc/ide/UppWspc.cpp +++ b/uppsrc/ide/UppWspc.cpp @@ -211,6 +211,7 @@ void WorkspaceWork::TouchFile(const String& path) void WorkspaceWork::PackageCursor() { + InvalidatePackageCache(); filelist.WhenBar.Clear(); actualpackage = GetActivePackage(); if(actualpackage.IsEmpty()) return;