ChangeNotesParser: Avoid lots of FooterLine allocations

The implementation of RevCommit#getFooterLines(String) always calls
getFooterLines(), which creates a new list filled with newly-parsed
FooterLine objects. This seems wasteful, especially considering in
ChangeNotes we call getFooterLines 10 or so times per commit.

Add a subclass of RevWalk that caches the result of getFooterLines in
a multimap. I don't claim that this is the most efficient
implementation possible, but it does give us the abstraction we need
to optimize more later.

Some tests were failing in a previous iteration of this change when I
didn't implement case-insensitive behavior. Normalize
ChangeNotesParserTest to use exactly-matching case in labels, except
for a single test method that explicitly tests case-folding behavior.

Change-Id: I836afa43cde2c1d8df04286664a3c6cc0fac57a9
This commit is contained in:
Dave Borowitz
2016-04-26 10:52:51 -04:00
parent e47cbbd9e6
commit 8e0b0a2b90
7 changed files with 210 additions and 87 deletions

View File

@@ -35,7 +35,6 @@ import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.notes.NoteMap;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import java.io.IOException;
@@ -169,7 +168,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
}
ObjectId draftsId = newState.getDraftIds().get(author);
repo.scanForRepoChanges();
return LoadHandle.create(new RevWalk(repo), draftsId);
return LoadHandle.create(ChangeNotesCommit.newRevWalk(repo), draftsId);
} catch (NoSuchChangeException e) {
return super.openHandle(repo);
} catch (OrmException | ConfigInvalidException e) {