Browse Source

MergeAlgorithm: Suppress Error Prone warning about reference equality

Error Prone reports:

  [ReferenceEquality] Comparison using reference equality instead of
  value equality

The END_EDIT instance is used as a marker, and thus it's OK to use
a reference equality comparison. Factor the comparison to a method
and add a suppression.

Change-Id: I7d9dc1fa21f46c984787056b0b5d163e313026a6
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.4
David Pursehouse 5 years ago committed by Matthias Sohn
parent
commit
6370098e54
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java

7
org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java

@ -86,6 +86,11 @@ public final class MergeAlgorithm {
private final static Edit END_EDIT = new Edit(Integer.MAX_VALUE,
Integer.MAX_VALUE);
@SuppressWarnings("ReferenceEquality")
private static boolean isEndEdit(Edit edit) {
return edit == END_EDIT;
}
/**
* Does the three way merge between a common base and two sequences.
*
@ -145,7 +150,7 @@ public final class MergeAlgorithm {
// iterate over all edits from base to ours and from base to theirs
// leave the loop when there are no edits more for ours or for theirs
// (or both)
while (theirsEdit != END_EDIT || oursEdit != END_EDIT) {
while (!isEndEdit(theirsEdit) || !isEndEdit(oursEdit)) {
if (oursEdit.getEndA() < theirsEdit.getBeginA()) {
// something was changed in ours not overlapping with any change
// from theirs. First add the common part in front of the edit

Loading…
Cancel
Save