JAL-2795 removed sequences[] class variable, more comments
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Wed, 1 Nov 2017 15:54:14 +0000 (15:54 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Wed, 1 Nov 2017 15:54:14 +0000 (15:54 +0000)
src/jalview/ext/forester/ForesterMatrix.java

index 92e88c8..e48ee27 100644 (file)
@@ -22,7 +22,6 @@ public class ForesterMatrix implements DistanceMatrix
 
   private final MatrixI jalviewMatrix;
 
-  private Sequence[] sequences;
 
   private final String[] identifiers;
 
@@ -30,12 +29,11 @@ public class ForesterMatrix implements DistanceMatrix
           final Sequence[] matrixSequences)
   {
     this.jalviewMatrix = jalviewInputMatrix;
-    this.sequences = matrixSequences;
-    this.identifiers = new String[sequences.length];
+    this.identifiers = new String[matrixSequences.length];
 
     int i = 0;
 
-    for (Sequence sequence : sequences)
+    for (Sequence sequence : matrixSequences)
     {
       identifiers[i] = sequence.getName();
       i++;
@@ -64,7 +62,9 @@ public class ForesterMatrix implements DistanceMatrix
     try {
     return IntStream.range(0, identifiers.length)
             .filter(x -> identifier.equals(identifiers[x])).findAny()
-            .getAsInt();
+              .getAsInt(); // stream to bypass otherwise having to duplicate the
+                           // list
+                           // with Arrays.aslist
     }
     catch (NoSuchElementException ex) {
       throw new Error(MessageManager.formatMessage(