Commit 0eef8004 authored by Andrey Filippov's avatar Andrey Filippov

Optimized list of dependency files - using cache

parent f2a02373
......@@ -127,7 +127,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
// TODO: Compare dependFiles with literary result of other tools, if match - these are states, not files
private List<Parameter> dependStates; // snapshot names
private List<Parameter> dependFiles;
private List<Parameter> dependFiles;
private List<String> dependFilesCache = null; // list of resolved file relative paths calculated earlier
private Map <String,String> dependStatesTimestamps;
private Map <String,String> dependFilesTimestamps;
......@@ -250,7 +251,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
restoreTool=null;
result=null;
dependStates=null;
dependFiles=null;
dependFiles=null;
dependFilesCache=null;
DEBUG_PRINT("Created tool"+name+" disabledString = "+disabledString);
pinned=false;
openState=null;
......@@ -668,28 +670,32 @@ public class Tool extends Context implements Cloneable, Inheritable {
}
}
}
}
}
public List<String> getDependFiles(){
DEBUG_PRINT("------ getDependFiles()");
setTreeReparse(true); // Set actual dependence
if ((dependFiles == null) || (dependFiles.size()==0)) return null;
List<String> list = new ArrayList<String>();
for (Iterator<Parameter> iter= dependFiles.iterator(); iter.hasNext();) {
List<String> vList=iter.next().getValue(new FormatProcessor(this)); // null for topFormatProcessor
if (vList!=null) {
for (String item:vList){
if ((item!=null) && (item.trim().length()>0)){
list.add(item.trim());
}
}
// list.addAll(vList);
}
}
for (String item:list){
dependFilesCache = null; //invalidate, will be recreated
}
public List<String> getDependFiles(boolean rebuild){
if (rebuild || (dependFilesCache == null)) {
DEBUG_PRINT("------ getDependFiles(rebuild="+rebuild+"), rebuilding");
setTreeReparse(true); // Set actual dependence
if ((dependFiles == null) || (dependFiles.size()==0)) return null;
dependFilesCache = new ArrayList<String>();
for (Iterator<Parameter> iter= dependFiles.iterator(); iter.hasNext();) {
List<String> vList=iter.next().getValue(new FormatProcessor(this)); // null for topFormatProcessor
if (vList!=null) {
for (String item:vList){
if ((item!=null) && (item.trim().length()>0)){
dependFilesCache.add(item.trim());
}
}
}
}
} else {
DEBUG_PRINT("------ getDependFiles(rebuild="+rebuild+"), using cache");
}
for (String item:dependFilesCache){
DEBUG_PRINT("-----> "+getName()+".getDependFiles()->"+item);
}
return list;
}
return dependFilesCache;
}
public List<String> getDependStates(){
......
......@@ -1720,8 +1720,9 @@ java.lang.NullPointerException
}
private Map <String,String> makeDependFiles(Tool tool, boolean failOnMissing){
DEBUG_PRINT("++++++ makeDependFiles("+tool.getName()+")");
Map <String,String> depFiles=new Hashtable<String,String>();
List<String> dependFileNames=tool.getDependFiles(); // files on which this tool depends - make cached version
Map <String,String> depFiles=new Hashtable<String,String>();
// Use depend files cache if available
List<String> dependFileNames=tool.getDependFiles(false); // files on which this tool depends - make cached version
if (dependFileNames!=null) {
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
for (String depFile: dependFileNames){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment