From 8dc6988893a2daaeb5df7507edf2b4535cac2e49 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 8 Jun 2017 09:23:09 +0100 Subject: [PATCH] JAL-2526 reuse findIndex result if start==end --- src/jalview/datamodel/SearchResults.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) 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) -- 1.7.10.2