Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-07-06 12:07:08 -0400
committerMichael Keppler2019-07-07 12:39:58 -0400
commit104d3ecfe02eb771f107fa0b892a2be646aa81ab (patch)
tree20e83ce42c1c0361b124bce49d97b628c89b8daf /org.eclipse.egit.ui/src/org/eclipse
parent10293f9f0c3739a66e772d7cd3e7560f7c4b7ccd (diff)
downloadegit-104d3ecfe02eb771f107fa0b892a2be646aa81ab.tar.gz
egit-104d3ecfe02eb771f107fa0b892a2be646aa81ab.tar.xz
egit-104d3ecfe02eb771f107fa0b892a2be646aa81ab.zip
Avoid duplicate entries in the history view's view history
With the history filtered to a resource, the view history of the history view itself contained many duplicate elements. This was caused by == comparisons instead of equals() in HistoryPageInput. Also improve HistoryPageInput.hashCode() to use the "standard" multiply-by-31 mechanism instead of xor. Change-Id: I8f1bde2bed52ac3ce52ec252fd5fcf735870ff3f Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/HistoryPageInput.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/HistoryPageInput.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/HistoryPageInput.java
index 8015ecc4c..6fb2938a0 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/HistoryPageInput.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/HistoryPageInput.java
@@ -19,6 +19,7 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
import org.eclipse.core.resources.IResource;
import org.eclipse.egit.ui.Activator;
@@ -212,8 +213,9 @@ public class HistoryPageInput {
return false;
}
HistoryPageInput other = (HistoryPageInput) obj;
- return repo == other.repo && singleFile == other.singleFile
- && singleItem == other.singleItem
+ return repo == other.repo
+ && Objects.equals(singleFile, other.singleFile)
+ && Objects.equals(singleItem, other.singleItem)
&& listEquals(files, other.files)
&& listEquals(list, other.list);
}
@@ -230,10 +232,13 @@ public class HistoryPageInput {
@Override
public int hashCode() {
- return (repo == null ? 0 : repo.hashCode())
- ^ (singleFile == null ? 0 : singleFile.hashCode())
- ^ (singleItem == null ? 0 : singleItem.hashCode())
- ^ (files == null ? 0 : Arrays.hashCode(files.toArray()))
- ^ (list == null ? 0 : Arrays.hashCode(list.toArray()));
+ int result = Objects.hash(repo, singleFile, singleItem);
+ if (files != null) {
+ result = 31 * result + Arrays.hashCode(files.toArray());
+ }
+ if (list != null) {
+ result = 31 * result + Arrays.hashCode(list.toArray());
+ }
+ return result;
}
}

Back to the top