From 5935396709349dbe2926fa1ad0dd24995712b77b Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 7 Oct 2015 12:51:27 +0100 Subject: [PATCH] JAL-1912 efficiency: look up sequenceMapping once per position and only when sequenceMapping!=null --- src/jalview/datamodel/AlignmentAnnotation.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/jalview/datamodel/AlignmentAnnotation.java b/src/jalview/datamodel/AlignmentAnnotation.java index 01926dc..b00f27d 100755 --- a/src/jalview/datamodel/AlignmentAnnotation.java +++ b/src/jalview/datamodel/AlignmentAnnotation.java @@ -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; } -- 1.7.10.2