Mercurial > jhg
diff src/org/tmatesoft/hg/repo/HgManifest.java @ 254:a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 16 Aug 2011 04:03:29 +0200 |
parents | b7347daa50e3 |
children | f39fb6b3cc76 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgManifest.java Mon Aug 15 18:59:05 2011 +0200 +++ b/src/org/tmatesoft/hg/repo/HgManifest.java Tue Aug 16 04:03:29 2011 +0200 @@ -60,6 +60,31 @@ content.iterate(start0, end0, true, new ManifestParser(inspector)); } + /** + * "Sparse" iteration of the manifest + * + * @param inspector + * @param localRevisions local changeset revisions to visit + */ + public void walk(final Inspector inspector, int... localRevisions) { + if (inspector == null || localRevisions == null) { + throw new IllegalArgumentException(); + } + int[] manifestLocalRevs = new int[localRevisions.length]; + boolean needsSort = false; + for (int i = 0; i < localRevisions.length; i++) { + final int manifestLocalRev = fromChangelog(localRevisions[i]); + manifestLocalRevs[i] = manifestLocalRev; + if (i > 0 && manifestLocalRevs[i-1] > manifestLocalRev) { + needsSort = true; + } + } + if (needsSort) { + Arrays.sort(manifestLocalRevs); + } + content.iterate(manifestLocalRevs, true, new ManifestParser(inspector)); + } + // manifest revision number that corresponds to the given changeset /*package-local*/ int fromChangelog(int revisionNumber) { if (HgInternals.wrongLocalRevision(revisionNumber)) {