From d360dff412aba57c53f05b2d75eec53678cdcd80 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Fri, 1 Feb 2019 09:42:13 +0000 Subject: [PATCH] JAL-3141 Slight efficiency gain in detecting backupfiles in the File Chooser --- src/jalview/io/JalviewFileFilter.java | 8 +++++++- src/jalview/io/JalviewFileView.java | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/jalview/io/JalviewFileFilter.java b/src/jalview/io/JalviewFileFilter.java index 8c6b802..bc20342 100755 --- a/src/jalview/io/JalviewFileFilter.java +++ b/src/jalview/io/JalviewFileFilter.java @@ -103,10 +103,16 @@ public class JalviewFileFilter extends FileFilter if (parentJFC != null && parentJFC.includeBackupFiles) { Iterator 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()) diff --git a/src/jalview/io/JalviewFileView.java b/src/jalview/io/JalviewFileView.java index 857d043..52d130c 100755 --- a/src/jalview/io/JalviewFileView.java +++ b/src/jalview/io/JalviewFileView.java @@ -94,9 +94,16 @@ public class JalviewFileView extends FileView if (type == null) { Iterator 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()) -- 1.7.10.2