From 5ea5764f835390ab631afbf54c2de40f63aa8f31 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Wed, 9 Mar 2022 16:31:24 +0100 Subject: [PATCH] JAL-3878 Improve performance of gap sequence construction. --- src/jalview/ws2/actions/alignment/AlignmentTask.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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) -- 1.7.10.2