From: Mateusz Warowny Date: Wed, 9 Mar 2022 15:31:24 +0000 (+0100) Subject: JAL-3878 Improve performance of gap sequence construction. X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5ea5764f835390ab631afbf54c2de40f63aa8f31;p=jalview.git JAL-3878 Improve performance of gap sequence construction. --- diff --git a/src/jalview/ws2/actions/alignment/AlignmentTask.java b/src/jalview/ws2/actions/alignment/AlignmentTask.java index 214cd02..96e9a12 100644 --- a/src/jalview/ws2/actions/alignment/AlignmentTask.java +++ b/src/jalview/ws2/actions/alignment/AlignmentTask.java @@ -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 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 } /** - * 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)