Browse Source

Compare modes before comparing ids in ResolveMerger

Comparing ids can be more expensive so do the cheap
mode check first and short circuit the id comparison
when modes are non-equal

Change-Id: I671eda51c74a411cc27de9d6077cc76e816ebe2b
stable-2.0
Kevin Sawicki 13 years ago
parent
commit
c403d0b187
  1. 4
      org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

4
org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

@ -556,7 +556,7 @@ public class ResolveMerger extends ThreeWayMerger {
// Index entry has to match ours to be considered clean // Index entry has to match ours to be considered clean
final boolean isDirty = nonTree(modeI) final boolean isDirty = nonTree(modeI)
&& !(tw.idEqual(T_INDEX, T_OURS) && modeO == modeI); && !(modeO == modeI && tw.idEqual(T_INDEX, T_OURS));
if (isDirty) if (isDirty)
failingPaths failingPaths
.put(tw.getPathString(), MergeFailureReason.DIRTY_INDEX); .put(tw.getPathString(), MergeFailureReason.DIRTY_INDEX);
@ -572,7 +572,7 @@ public class ResolveMerger extends ThreeWayMerger {
// Worktree entry has to match ours to be considered clean // Worktree entry has to match ours to be considered clean
final boolean isDirty = nonTree(modeF) final boolean isDirty = nonTree(modeF)
&& !(tw.idEqual(T_FILE, T_OURS) && modeO == modeF); && !(modeO == modeF && tw.idEqual(T_FILE, T_OURS));
if (isDirty) if (isDirty)
failingPaths.put(tw.getPathString(), failingPaths.put(tw.getPathString(),
MergeFailureReason.DIRTY_WORKTREE); MergeFailureReason.DIRTY_WORKTREE);

Loading…
Cancel
Save