]> source.dussan.org Git - jgit.git/commitdiff
Compare modes before comparing ids in ResolveMerger 09/5909/1
authorKevin Sawicki <kevin@github.com>
Wed, 9 May 2012 21:31:59 +0000 (14:31 -0700)
committerKevin Sawicki <kevin@github.com>
Wed, 9 May 2012 21:31:59 +0000 (14:31 -0700)
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

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

index 339dbdda415c5329f13173f23c930b91c81001c5..261aa9f0a81f0a413b858aac31ecb8760604d8b9 100644 (file)
@@ -556,7 +556,7 @@ public class ResolveMerger extends ThreeWayMerger {
 
                // Index entry has to match ours to be considered clean
                final boolean isDirty = nonTree(modeI)
-                               && !(tw.idEqual(T_INDEX, T_OURS) && modeO == modeI);
+                               && !(modeO == modeI && tw.idEqual(T_INDEX, T_OURS));
                if (isDirty)
                        failingPaths
                                        .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
                final boolean isDirty = nonTree(modeF)
-                               && !(tw.idEqual(T_FILE, T_OURS) && modeO == modeF);
+                               && !(modeO == modeF && tw.idEqual(T_FILE, T_OURS));
                if (isDirty)
                        failingPaths.put(tw.getPathString(),
                                        MergeFailureReason.DIRTY_WORKTREE);