diff src/org/tmatesoft/hg/repo/Revlog.java @ 694:7efabe0cddcf

Speed up (a) file rename history to minimize file reads; (b) file.isCopy(int) to read metadata for few revisions at once (use pattern assumes earlier revisions are likely to be queried, too); (c) HgIgnore.isIgnored by caching matched initial fragments (to substitute more expensive Matcher.matches with cheaper HashMap.contains)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 05 Aug 2013 17:42:10 +0200
parents 32b0d19e8aba
children 053bb4397bf9
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/Revlog.java	Mon Aug 05 12:45:36 2013 +0200
+++ b/src/org/tmatesoft/hg/repo/Revlog.java	Mon Aug 05 17:42:10 2013 +0200
@@ -334,6 +334,8 @@
 	 * EXPERIMENTAL CODE, DO NOT USE
 	 * 
 	 * Alternative revlog iteration
+	 * There's an implicit ordering of inspectors. Less inspector needs, earlier its invocation occurs.
+	 * E.g. ParentInspector goes after RevisionInspector. LinkRevisionInspector goes before RevisionInspector
 	 * 
 	 * @param start
 	 * @param end
@@ -349,6 +351,7 @@
 		}
 		final RevisionInspector revisionInsp = Adaptable.Factory.getAdapter(inspector, RevisionInspector.class, null);
 		final ParentInspector parentInsp = Adaptable.Factory.getAdapter(inspector, ParentInspector.class, null);
+		final LinkRevisionInspector linkRevInspector = Adaptable.Factory.getAdapter(inspector, LinkRevisionInspector.class, null);
 		final Nodeid[] allRevisions = parentInsp == null ? null : new Nodeid[end - _start + 1];
 		// next are to build set of parent indexes that are not part of the range iteration
 		// i.e. those parents we need to read separately. See Issue 31 for details.
@@ -360,6 +363,14 @@
 			private int i = 0;
 			
 			public void next(int revisionIndex, int actualLen, int baseRevIndex, int linkRevIndex, int parent1RevIndex, int parent2RevIndex, byte[] nodeid, DataAccess data) throws HgRuntimeException {
+				// FIXME refactor either as chain of RevlogStream.Inspector or an external AnyOf() runner not to keep everything
+				// in a single method
+				if (linkRevInspector != null) {
+					linkRevInspector.next(revisionIndex, linkRevIndex);
+					if (parentInsp == null && revisionInsp == null) {
+						return;
+					}
+				}
 				Nodeid nid = Nodeid.fromBinary(nodeid, 0);
 				if (revisionInsp != null) {
 					revisionInsp.next(revisionIndex, nid, linkRevIndex);
@@ -440,6 +451,11 @@
 	}
 
 	@Experimental
+	public interface LinkRevisionInspector extends Inspector {
+		void next(int revisionIndex, int linkedRevisionIndex) throws HgRuntimeException;
+	}
+
+	@Experimental
 	public interface ParentInspector extends Inspector {
 		// XXX document whether parentX is -1 or a constant (BAD_REVISION? or dedicated?)
 		void next(int revisionIndex, Nodeid revision, int parent1, int parent2, Nodeid nidParent1, Nodeid nidParent2) throws HgRuntimeException;