From caa89ac856d432b159653d92d2f6fbb001dc42d6 Mon Sep 17 00:00:00 2001 From: kiramt Date: Wed, 22 Nov 2017 10:22:20 +0000 Subject: [PATCH] JAL-2759 performance tweaks --- src/jalview/datamodel/HiddenColumns.java | 4 ++- src/jalview/datamodel/HiddenColumnsCursor.java | 36 +++++++++++++++--------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/jalview/datamodel/HiddenColumns.java b/src/jalview/datamodel/HiddenColumns.java index 4e57aa1..fa5d0a0 100644 --- a/src/jalview/datamodel/HiddenColumns.java +++ b/src/jalview/datamodel/HiddenColumns.java @@ -924,7 +924,9 @@ public class HiddenColumns if (regionindex > -1 && regionindex < hiddenColumns.size()) { int[] region = hiddenColumns.get(regionindex); - if (column >= region[0] && column <= region[1]) + // already know that column <= region[1] as cursor returns containing + // region or region to right + if (column >= region[0]) { return false; } diff --git a/src/jalview/datamodel/HiddenColumnsCursor.java b/src/jalview/datamodel/HiddenColumnsCursor.java index a002232..04d7189 100644 --- a/src/jalview/datamodel/HiddenColumnsCursor.java +++ b/src/jalview/datamodel/HiddenColumnsCursor.java @@ -87,12 +87,11 @@ public class HiddenColumnsCursor { // deleted last region, index is now end of alignment index = hiddenCols.size(); - } - // update the cursor position - HiddenCursorPosition newpos = new HiddenCursorPosition(index, - oldpos.getHiddenSoFar()); - cursorPos.compareAndSet(oldpos, newpos); + HiddenCursorPosition newpos = new HiddenCursorPosition(index, + oldpos.getHiddenSoFar()); + cursorPos.compareAndSet(oldpos, newpos); + } } hiddenColumns = hiddenCols; } @@ -169,10 +168,16 @@ public class HiddenColumnsCursor } } } - HiddenCursorPosition newpos = new HiddenCursorPosition(index, - hiddenCount); - cursorPos.compareAndSet(oldpos, newpos); - return newpos; + + if (index != oldpos.getRegionIndex() + || hiddenCount != oldpos.getHiddenSoFar()) + { + HiddenCursorPosition newpos = new HiddenCursorPosition(index, + hiddenCount); + cursorPos.compareAndSet(oldpos, newpos); + return newpos; + } + return oldpos; } /** @@ -224,9 +229,14 @@ public class HiddenColumnsCursor } - HiddenCursorPosition newpos = new HiddenCursorPosition(index, - hiddenCount); - cursorPos.compareAndSet(oldpos, newpos); - return newpos; + if (index != oldpos.getRegionIndex() + || hiddenCount != oldpos.getHiddenSoFar()) + { + HiddenCursorPosition newpos = new HiddenCursorPosition(index, + hiddenCount); + cursorPos.compareAndSet(oldpos, newpos); + return newpos; + } + return oldpos; } } -- 1.7.10.2