From bda14302200fc3bcfe66dc513bd030cba10a3681 Mon Sep 17 00:00:00 2001 From: kiramt Date: Fri, 2 Jun 2017 14:10:57 +0100 Subject: [PATCH] JAL-2576 Proposed fix --- src/jalview/datamodel/Alignment.java | 9 +++------ src/jalview/util/LinkedIdentityHashSet.java | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 5d91b36..f5e6fc7 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -1067,21 +1067,18 @@ public class Alignment implements AlignmentI currentSeq = currentSeq.createDatasetSequence(); } } - if (seqs.contains(currentSeq)) - { - return; - } + List toProcess = new ArrayList<>(); toProcess.add(currentSeq); while (toProcess.size() > 0) { // use a queue ? SequenceI curDs = toProcess.remove(0); - if (seqs.contains(curDs)) + + if (!seqs.add(curDs)) { continue; } - seqs.add(curDs); // iterate over database references, making sure we add forward referenced // sequences if (curDs.getDBRefs() != null) diff --git a/src/jalview/util/LinkedIdentityHashSet.java b/src/jalview/util/LinkedIdentityHashSet.java index bce540f..7f109ec 100644 --- a/src/jalview/util/LinkedIdentityHashSet.java +++ b/src/jalview/util/LinkedIdentityHashSet.java @@ -34,7 +34,7 @@ import java.util.LinkedHashMap; */ public class LinkedIdentityHashSet extends AbstractSet { - LinkedHashMap set = new LinkedHashMap(); + LinkedHashMap set = new LinkedHashMap<>(); static class IdentityWrapper { @@ -51,7 +51,7 @@ public class LinkedIdentityHashSet extends AbstractSet @Override public boolean equals(Object obj) { - return this.obj == obj; + return this.obj == ((IdentityWrapper) obj).obj; } @Override -- 1.7.10.2