Improve the export command performance

The export command used to iterate over changes, take the commit id of the
current patch set and then use that commit id to load the (same) patch set
again. Instead of doing that nonsense just use the (already loaded) current
patch set.

Change-Id: Ibd4f129531f8b52c180f5ba44c71f94e50f488ae
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
index 83a25ab..4e8642c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
@@ -160,7 +160,7 @@
         PatchSet ps = reviewDb.patchSets().get(c.currentPatchSetId());
         ObjectId commitId = ObjectId.fromString(ps.getRevision().get());
         RevCommit commit = rw.parseCommit(commitId);
-        getNotes().set(commitId, createNoteContent(commit));
+        getNotes().set(commitId, createNoteContent(ps));
         getMessage().append("* ").append(commit.getShortMessage()).append("\n");
       }
     } finally {
@@ -209,11 +209,10 @@
     }
   }
 
-  private ObjectId createNoteContent(RevCommit c)
+  private ObjectId createNoteContent(PatchSet ps)
       throws OrmException, IOException {
     HeaderFormatter fmt =
         new HeaderFormatter(gerritServerIdent.getTimeZone(), anonymousCowardName);
-    PatchSet ps = loadPatchSet(c);
     if (ps != null) {
       try {
         createCodeReviewNote(ps, fmt);
@@ -226,6 +225,11 @@
     return null;
   }
 
+  private ObjectId createNoteContent(RevCommit c)
+      throws OrmException, IOException {
+    return createNoteContent(loadPatchSet(c));
+  }
+
   private PatchSet loadPatchSet(RevCommit c) throws OrmException {
     List<PatchSet> patches = reviewDb.patchSets().byRevision(new RevId(c.name()))
         .toList();