Mercurial > hg4j
comparison 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 |
comparison
equal
deleted
inserted
replaced
253:1874d11054e5 | 254:a620f0663a37 |
---|---|
56 throw new IllegalArgumentException(); | 56 throw new IllegalArgumentException(); |
57 } | 57 } |
58 int start0 = fromChangelog(start); | 58 int start0 = fromChangelog(start); |
59 int end0 = fromChangelog(end); | 59 int end0 = fromChangelog(end); |
60 content.iterate(start0, end0, true, new ManifestParser(inspector)); | 60 content.iterate(start0, end0, true, new ManifestParser(inspector)); |
61 } | |
62 | |
63 /** | |
64 * "Sparse" iteration of the manifest | |
65 * | |
66 * @param inspector | |
67 * @param localRevisions local changeset revisions to visit | |
68 */ | |
69 public void walk(final Inspector inspector, int... localRevisions) { | |
70 if (inspector == null || localRevisions == null) { | |
71 throw new IllegalArgumentException(); | |
72 } | |
73 int[] manifestLocalRevs = new int[localRevisions.length]; | |
74 boolean needsSort = false; | |
75 for (int i = 0; i < localRevisions.length; i++) { | |
76 final int manifestLocalRev = fromChangelog(localRevisions[i]); | |
77 manifestLocalRevs[i] = manifestLocalRev; | |
78 if (i > 0 && manifestLocalRevs[i-1] > manifestLocalRev) { | |
79 needsSort = true; | |
80 } | |
81 } | |
82 if (needsSort) { | |
83 Arrays.sort(manifestLocalRevs); | |
84 } | |
85 content.iterate(manifestLocalRevs, true, new ManifestParser(inspector)); | |
61 } | 86 } |
62 | 87 |
63 // manifest revision number that corresponds to the given changeset | 88 // manifest revision number that corresponds to the given changeset |
64 /*package-local*/ int fromChangelog(int revisionNumber) { | 89 /*package-local*/ int fromChangelog(int revisionNumber) { |
65 if (HgInternals.wrongLocalRevision(revisionNumber)) { | 90 if (HgInternals.wrongLocalRevision(revisionNumber)) { |