JAL-3878 Improve performance of gap sequence construction.
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 9 Mar 2022 15:31:24 +0000 (16:31 +0100)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 9 Mar 2022 15:31:24 +0000 (16:31 +0100)
src/jalview/ws2/actions/alignment/AlignmentTask.java

index 214cd02..96e9a12 100644 (file)
@@ -4,6 +4,7 @@ import static java.lang.String.format;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -153,8 +154,12 @@ class AlignmentTask extends AbstractPollableTask<AlignmentJob, AlignmentResult>
       for (var seq: alnSeqs)
         width = Integer.max(width, seq.getLength());
       // make a sequence of gaps only to cut/paste
-      String gapSeq = String.join("",
-          Collections.nCopies(width, Character.toString(gapChar)));
+      String gapSeq;
+      {
+        char[] gaps = new char[width];
+        Arrays.fill(gaps, gapChar);
+        gapSeq = new String(gaps);
+      }
       for (var seq: alnSeqs)
       {
         if (seq.getLength() < width)
@@ -193,9 +198,8 @@ class AlignmentTask extends AbstractPollableTask<AlignmentJob, AlignmentResult>
   }
   
   /**
-   * Conserve dataset references to sequence objects returned from
-   * web services. Propagate AlignedCodonFrame data from {@code codonFrame}
-   * to {@code aln}.
+   * Conserve dataset references to sequence objects returned from web services.
+   * Propagate AlignedCodonFrame data from {@code codonFrame} to {@code aln}.
    * TODO: Refactor to datamodel
    */
   private void propagateDatasetMappings(AlignmentI aln)