From e5b94879d47f328b2272072c06a6dc500c3f90aa Mon Sep 17 00:00:00 2001 From: kiramt Date: Wed, 22 Nov 2017 15:05:01 +0000 Subject: [PATCH] JAL-2759 code tidy --- src/jalview/datamodel/HiddenColumnsCursor.java | 26 ++++++++---------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/jalview/datamodel/HiddenColumnsCursor.java b/src/jalview/datamodel/HiddenColumnsCursor.java index 9cb3298..3d82ee7 100644 --- a/src/jalview/datamodel/HiddenColumnsCursor.java +++ b/src/jalview/datamodel/HiddenColumnsCursor.java @@ -144,21 +144,15 @@ public class HiddenColumnsCursor hiddenCount -= region[1] - region[0] + 1; } - if ((hiddenColumns.get(index)[0] <= column) - && hiddenColumns.get(index)[1] >= column) - { - // column is in the current region - // we hit the jackpot - // don't need to move index - } - else if (column < firstColumn) + // this if statement excludes case where column is in current region + // - no changes needed + if (column < firstColumn) { index = 0; hiddenCount = 0; } // column is after current region - else if (column > hiddenColumns.get(index)[1]) // includes if column > - // lastColumn + else if (column > hiddenColumns.get(index)[1]) { // iterate from where we are now, if we're lucky we'll be close by // (but still better than iterating from 0) @@ -172,19 +166,15 @@ public class HiddenColumnsCursor index++; } } - // column is before current region else if (column < hiddenColumns.get(index)[0]) { // column is before or in the previous region - if ((index > 0) && (hiddenColumns.get(index - 1)[1] >= column)) + while ((index > 0) && (hiddenColumns.get(index - 1)[1] >= column)) { - while ((index > 0) && (hiddenColumns.get(index - 1)[1] >= column)) - { - index--; - int[] region = hiddenColumns.get(index); - hiddenCount -= region[1] - region[0] + 1; - } + index--; + int[] region = hiddenColumns.get(index); + hiddenCount -= region[1] - region[0] + 1; } } -- 1.7.10.2