Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6655730

Improve the performance of the LoadFilesThread class in BasicDirectoryModel

XMLWordPrintable

      A DESCRIPTION OF THE REQUEST :
      The LoadFilesThread class in javax.swing.plaf.basic.BasicDirectoryModel could be made more efficient. There are loops that compute the length of the array on each loop as in the following:
       for (int i = 0; i < list.length; i++) {
                              if(filechooser.accept(list[i])) {
                                  acceptsList.addElement(list[i]);
                              }
                          }


      JUSTIFICATION :
      JFileChooser performance is paramount in order to make it fast. Many people have complained that it is slow when loading directories with huge number of files. Implementing the fix will improve on that.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would do the following instead:
       for (int i = 0, size = list.length; i < size; i++) {
                              if(filechooser.accept(list[i])) {
                                  acceptsList.addElement(list[i]);
                              }
                          }
      That way the list's length is just computed once.

            rupashka Pavel Porvatov (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: