JAL-2526 reuse findIndex result if start==end
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 8 Jun 2017 08:23:09 +0000 (09:23 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 8 Jun 2017 08:23:09 +0000 (09:23 +0100)
src/jalview/datamodel/SearchResults.java

index 1bf5475..8d98fc4 100755 (executable)
@@ -219,20 +219,15 @@ public class SearchResults implements SearchResultsI
       m = (Match) _m;
 
       mfound = false;
-      if (m.sequence == sequence)
+      if (m.sequence == sequence
+              || m.sequence == sequence.getDatasetSequence())
       {
         mfound = true;
-        // locate aligned position
         matchStart = sequence.findIndex(m.start) - 1;
-        matchEnd = sequence.findIndex(m.end) - 1;
-      }
-      else if (m.sequence == sequence.getDatasetSequence())
-      {
-        mfound = true;
-        // locate region in local context
-        matchStart = sequence.findIndex(m.start) - 1;
-        matchEnd = sequence.findIndex(m.end) - 1;
+        matchEnd = m.start == m.end ? matchStart : sequence
+                .findIndex(m.end) - 1;
       }
+
       if (mfound)
       {
         if (matchStart <= end && matchEnd >= start)