JAL-3141 Slight efficiency gain in detecting backupfiles in the File Chooser
authorBen Soares <bsoares@dundee.ac.uk>
Fri, 1 Feb 2019 09:42:13 +0000 (09:42 +0000)
committerBen Soares <bsoares@dundee.ac.uk>
Fri, 1 Feb 2019 09:42:13 +0000 (09:42 +0000)
src/jalview/io/JalviewFileFilter.java
src/jalview/io/JalviewFileView.java

index 8c6b802..bc20342 100755 (executable)
@@ -103,10 +103,16 @@ public class JalviewFileFilter extends FileFilter
     if (parentJFC != null && parentJFC.includeBackupFiles)
     {
       Iterator<String> it = filters.keySet().iterator();
-      while (it.hasNext())
+      EXTENSION: while (it.hasNext())
       {
         String ext = it.next();
 
+        // quick negative test
+        if (!f.getName().contains(ext))
+        {
+          continue EXTENSION;
+        }
+
         BackupFilenameParts bfp = BackupFilenameParts
                 .currentBackupFilenameParts(f.getName(), ext, true);
         if (bfp.isBackupFile())
index 857d043..52d130c 100755 (executable)
@@ -94,9 +94,16 @@ public class JalviewFileView extends FileView
     if (type == null)
     {
       Iterator<String> it = extensions.keySet().iterator();
-      while (it.hasNext())
+      EXTENSION: while (it.hasNext())
       {
         String ext = it.next();
+
+        // quick negative test
+        if (!f.getName().contains(ext))
+        {
+          continue EXTENSION;
+        }
+
         BackupFilenameParts bfp = BackupFilenameParts
                 .currentBackupFilenameParts(f.getName(), ext, true);
         if (bfp.isBackupFile())