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

Optimized list of dependency files - using cache

parent f2a02373
...@@ -128,6 +128,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -128,6 +128,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
// TODO: Compare dependFiles with literary result of other tools, if match - these are states, not files // 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> 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> dependStatesTimestamps;
private Map <String,String> dependFilesTimestamps; private Map <String,String> dependFilesTimestamps;
...@@ -251,6 +252,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -251,6 +252,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
result=null; result=null;
dependStates=null; dependStates=null;
dependFiles=null; dependFiles=null;
dependFilesCache=null;
DEBUG_PRINT("Created tool"+name+" disabledString = "+disabledString); DEBUG_PRINT("Created tool"+name+" disabledString = "+disabledString);
pinned=false; pinned=false;
openState=null; openState=null;
...@@ -669,27 +671,31 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -669,27 +671,31 @@ public class Tool extends Context implements Cloneable, Inheritable {
} }
} }
} }
dependFilesCache = null; //invalidate, will be recreated
} }
public List<String> getDependFiles(){ public List<String> getDependFiles(boolean rebuild){
DEBUG_PRINT("------ getDependFiles()"); if (rebuild || (dependFilesCache == null)) {
DEBUG_PRINT("------ getDependFiles(rebuild="+rebuild+"), rebuilding");
setTreeReparse(true); // Set actual dependence setTreeReparse(true); // Set actual dependence
if ((dependFiles == null) || (dependFiles.size()==0)) return null; if ((dependFiles == null) || (dependFiles.size()==0)) return null;
List<String> list = new ArrayList<String>(); dependFilesCache = new ArrayList<String>();
for (Iterator<Parameter> iter= dependFiles.iterator(); iter.hasNext();) { for (Iterator<Parameter> iter= dependFiles.iterator(); iter.hasNext();) {
List<String> vList=iter.next().getValue(new FormatProcessor(this)); // null for topFormatProcessor List<String> vList=iter.next().getValue(new FormatProcessor(this)); // null for topFormatProcessor
if (vList!=null) { if (vList!=null) {
for (String item:vList){ for (String item:vList){
if ((item!=null) && (item.trim().length()>0)){ if ((item!=null) && (item.trim().length()>0)){
list.add(item.trim()); dependFilesCache.add(item.trim());
} }
} }
// list.addAll(vList);
} }
} }
for (String item:list){ } else {
DEBUG_PRINT("------ getDependFiles(rebuild="+rebuild+"), using cache");
}
for (String item:dependFilesCache){
DEBUG_PRINT("-----> "+getName()+".getDependFiles()->"+item); DEBUG_PRINT("-----> "+getName()+".getDependFiles()->"+item);
} }
return list; return dependFilesCache;
} }
public List<String> getDependStates(){ public List<String> getDependStates(){
......
...@@ -1721,7 +1721,8 @@ java.lang.NullPointerException ...@@ -1721,7 +1721,8 @@ java.lang.NullPointerException
private Map <String,String> makeDependFiles(Tool tool, boolean failOnMissing){ private Map <String,String> makeDependFiles(Tool tool, boolean failOnMissing){
DEBUG_PRINT("++++++ makeDependFiles("+tool.getName()+")"); DEBUG_PRINT("++++++ makeDependFiles("+tool.getName()+")");
Map <String,String> depFiles=new Hashtable<String,String>(); Map <String,String> depFiles=new Hashtable<String,String>();
List<String> dependFileNames=tool.getDependFiles(); // files on which this tool depends - make cached version // Use depend files cache if available
List<String> dependFileNames=tool.getDependFiles(false); // files on which this tool depends - make cached version
if (dependFileNames!=null) { if (dependFileNames!=null) {
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
for (String depFile: dependFileNames){ 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