PackagePath cache (may resolve observed theide key lag...)

git-svn-id: svn://ultimatepp.org/upp/trunk@1161 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-05-12 08:01:25 +00:00
parent dfe15080d7
commit ee152d30f4
4 changed files with 24 additions and 1 deletions

View file

@ -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

View file

@ -173,7 +173,15 @@ bool IsFolder(const String& path)
return ff && ff.IsDirectory();
}
String PackagePath(const String& name) {
VectorMap<String, String> package_cache;
void InvalidatePackageCache()
{
package_cache.Clear();
}
String PackagePath0(const String& name)
{
String uppfile = NativePath(name);
if(IsFullPath(uppfile)) return NormalizePath(uppfile);
Vector<String> 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));

View file

@ -576,6 +576,7 @@ PackageEditor::PackageEditor()
}
void EditPackages(const char *main, const char *startwith, String& cfg) {
InvalidatePackageCache();
PackageEditor pe;
pe.Sizeable();
StringStream in(cfg);

View file

@ -211,6 +211,7 @@ void WorkspaceWork::TouchFile(const String& path)
void WorkspaceWork::PackageCursor()
{
InvalidatePackageCache();
filelist.WhenBar.Clear();
actualpackage = GetActivePackage();
if(actualpackage.IsEmpty()) return;