From: gmungoc Date: Thu, 8 Jun 2017 08:23:09 +0000 (+0100) Subject: JAL-2526 reuse findIndex result if start==end X-Git-Tag: Release_2_10_3b1~208 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8dc6988893a2daaeb5df7507edf2b4535cac2e49;p=jalview.git JAL-2526 reuse findIndex result if start==end --- diff --git a/src/jalview/datamodel/SearchResults.java b/src/jalview/datamodel/SearchResults.java index 1bf5475..8d98fc4 100755 --- a/src/jalview/datamodel/SearchResults.java +++ b/src/jalview/datamodel/SearchResults.java @@ -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)