JAL-1382 slightly more efficient detection of non-gap entry in deleted region of...
authorJim Procter <jprocter@dundee.ac.uk>
Tue, 10 Feb 2015 14:57:50 +0000 (14:57 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Tue, 10 Feb 2015 14:57:50 +0000 (14:57 +0000)
src/jalview/datamodel/Sequence.java

index fb559eb..1479d94 100755 (executable)
@@ -729,9 +729,10 @@ public class Sequence implements SequenceI
 
     char[] tmp = StringUtils.deleteChars(sequence, i, j);
     boolean createNewDs = false;
-    // TODO: take a look at the new dataset creation validation method below -
-    // this could become time comsuming for large sequences - consider making it
-    // more efficient
+    // TODO: take a (second look) at the dataset creation validation method for
+    // the very large sequence case
+    int eindex = -1, sindex = -1;
+    boolean ecalc = false, scalc = false;
     for (int s = i; s < j; s++)
     {
       if (jalview.schemes.ResidueProperties.aaIndex[sequence[s]] != 23)
@@ -742,7 +743,11 @@ public class Sequence implements SequenceI
         }
         else
         {
-          int sindex = findIndex(start) - 1;
+          if (!scalc)
+          {
+            sindex = findIndex(start) - 1;
+            scalc = true;
+          }
           if (sindex == s)
           {
             // delete characters including start of sequence
@@ -752,7 +757,11 @@ public class Sequence implements SequenceI
           else
           {
             // delete characters after start.
-            int eindex = findIndex(end) - 1;
+            if (!ecalc)
+            {
+              eindex = findIndex(end) - 1;
+              ecalc = true;
+            }
             if (eindex < j)
             {
               // delete characters at end of sequence