diff src/org/tmatesoft/hg/core/HgLogCommand.java @ 195:c9b305df0b89

Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 15 Apr 2011 05:17:44 +0200
parents 37f3d4a596e4
children ffc5f6d59f7e
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgLogCommand.java	Fri Apr 15 03:35:08 2011 +0200
+++ b/src/org/tmatesoft/hg/core/HgLogCommand.java	Fri Apr 15 05:17:44 2011 +0200
@@ -59,6 +59,7 @@
 	private Path file;
 	private boolean followHistory; // makes sense only when file != null
 	private ChangesetTransformer csetTransform;
+	private HgChangelog.ParentWalker parentHelper;
 	
 	public HgLogCommand(HgRepository hgRepo) {
 		repo = hgRepo;
@@ -184,9 +185,13 @@
 		}
 		try {
 			count = 0;
+			HgChangelog.ParentWalker pw = parentHelper; // leave it uninitialized unless we iterate whole repo
+			if (file == null) {
+				pw = getParentHelper();
+			}
 			// ChangesetTransfrom creates a blank PathPool, and #file(String, boolean) above 
 			// may utilize it as well. CommandContext? How about StatusCollector there as well?
-			csetTransform = new ChangesetTransformer(repo, handler);
+			csetTransform = new ChangesetTransformer(repo, handler, pw);
 			if (file == null) {
 				repo.getChangelog().range(startRev, endRev, this);
 			} else {
@@ -244,6 +249,15 @@
 		count++;
 		csetTransform.next(revisionNumber, nodeid, cset);
 	}
+	
+	private HgChangelog.ParentWalker getParentHelper() {
+		if (parentHelper == null) {
+			parentHelper = repo.getChangelog().new ParentWalker();
+			parentHelper.init();
+		}
+		return parentHelper;
+	}
+
 
 	public interface Handler {
 		/**