JAL-1912 efficiency: look up sequenceMapping once per position and only when sequence...
authorJim Procter <jprocter@issues.jalview.org>
Wed, 7 Oct 2015 11:51:27 +0000 (12:51 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 7 Oct 2015 11:51:27 +0000 (12:51 +0100)
src/jalview/datamodel/AlignmentAnnotation.java

index 01926dc..b00f27d 100755 (executable)
@@ -980,18 +980,20 @@ public class AlignmentAnnotation
     int position;
     Annotation[] temp = new Annotation[aSize];
     Integer index;
-
-    for (a = sequenceRef.getStart(); a <= sequenceRef.getEnd(); a++)
+    if (sequenceMapping != null)
     {
-      index = new Integer(a);
-      if (sequenceMapping != null && sequenceMapping.containsKey(index))
+      for (a = sequenceRef.getStart(); a <= sequenceRef.getEnd(); a++)
       {
-        position = sequenceRef.findIndex(a) - 1;
+        index = new Integer(a);
+        Annotation annot = sequenceMapping.get(index);
+        if (annot != null)
+        {
+          position = sequenceRef.findIndex(a) - 1;
 
-        temp[position] = sequenceMapping.get(index);
+          temp[position] = annot;
+        }
       }
     }
-
     annotations = temp;
   }