Changeset 2193


Ignore:
Timestamp:
01/31/07 15:43:45 (13 years ago)
Author:
chris
Message:

Build used files list lazily, to avoid calling
initFile on every constituent file in the set.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/FileStitcher.java

    r2182 r2193  
    6161  /** The matching files. */ 
    6262  private String[] files; 
     63 
     64  /** Used files list. */ 
     65  private String[] usedFiles; 
    6366 
    6467  /** Reader used for each file. */ 
     
    488491  public String[] getUsedFiles(String id) throws FormatException, IOException { 
    489492    if (!id.equals(currentId)) initFile(id); 
    490     return files; 
     493    if (usedFiles == null) { 
     494      String[][] used = new String[files.length][]; 
     495      int total = files.length; 
     496      for (int i=0; i<files.length; i++) { 
     497        used[i] = reader.getUsedFiles(files[i]); 
     498        total += used[i].length; 
     499      } 
     500      usedFiles = new String[total]; 
     501      for (int i=0, off=0; i<used.length; i++) { 
     502        System.arraycopy(used[i], 0, usedFiles, off, used[i].length);  
     503        off += used[i].length; 
     504      } 
     505    } 
     506    return usedFiles; 
    491507  } 
    492508 
     
    720736    setSeries(currentId, oldSeries); 
    721737   
    722     String[][] s = new String[files.length][]; 
    723     int total = files.length; 
    724     for (int i=0; i<files.length; i++) { 
    725       s[i] = reader.getUsedFiles(files[i]); 
    726       total += s[i].length; 
    727     } 
    728     String[] tmp = files; 
    729     files = new String[total]; 
    730     System.arraycopy(tmp, 0, files, 0, tmp.length); 
    731     int off = tmp.length; 
    732     for (int i=0; i<s.length; i++) { 
    733       System.arraycopy(s[i], 0, files, off, s[i].length);  
    734       off += s[i].length; 
    735     } 
     738    // initialize used files list only when requested 
     739    usedFiles = null; 
    736740  } 
    737741 
Note: See TracChangeset for help on using the changeset viewer.