minor optimization
authorpavel.sher <pavel.sher@gmail.com>
Thu, 19 Jul 2018 21:44:54 +0000 (23:44 +0200)
committerpavel.sher <pavel.sher@gmail.com>
Thu, 19 Jul 2018 21:45:54 +0000 (23:45 +0200)
(cherry picked from commit 657ee1d)

git-server/src/jetbrains/buildServer/buildTriggers/vcs/git/GitMapFullPath.java

index 9bc7464c94075e5376038fc3cc7792a63e661980..a3abc3958095b8a53600c1eac6e73d1341bc15f6 100644 (file)
@@ -192,6 +192,11 @@ public class GitMapFullPath {
         uninteresting.add(oldRef.getObjectId());
     }
 
+    if (updatedHeads.isEmpty()) {
+      // avoid expensive RevWalk.parseAny for uninteresting heads if there are no updated heads
+      return Collections.emptySet();
+    }
+
     RevWalk revWalk = new RevWalk(db);
     try {
       revWalk.sort(RevSort.TOPO);
@@ -206,7 +211,7 @@ public class GitMapFullPath {
           revWalk.markUninteresting((RevCommit) obj);
       }
       Set<String> newCommits = new HashSet<String>();
-      RevCommit newCommit = null;
+      RevCommit newCommit;
       while ((newCommit = revWalk.next()) != null) {
         newCommits.add(newCommit.name());
       }