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

Optimized list of dependency files - using cache

parent f2a02373
Loading
Loading
Loading
Loading
+28 −22
Original line number Diff line number Diff line
@@ -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
    private List<Parameter> dependStates; // snapshot names
    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;
@@ -251,6 +252,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
        result=null;
        dependStates=null;
        dependFiles=null;
        dependFilesCache=null;
		DEBUG_PRINT("Created tool"+name+" disabledString = "+disabledString);
        pinned=false;
        openState=null;
@@ -669,27 +671,31 @@ public class Tool extends Context implements Cloneable, Inheritable {
    			}
    		}
    	}
    	dependFilesCache = null; //invalidate, will be recreated
    }
    public List<String> getDependFiles(){
    	DEBUG_PRINT("------ getDependFiles()");
    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;
    	List<String> list = new ArrayList<String>();
	    	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)){
    					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);
    	}
    	return list;
    	return dependFilesCache;
    }

    public List<String> getDependStates(){
+3 −2
Original line number Diff line number Diff line
@@ -1721,7 +1721,8 @@ 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
    	// 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){