Mercurial > jhg
diff src/org/tmatesoft/hg/repo/Revlog.java @ 604:c3505001a42a
Use nodeid reverse lookup speedup cache for #isKnown, if available
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 06 May 2013 18:53:04 +0200 |
parents | 8143c1f77d45 |
children | 66f1cc23b906 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/Revlog.java Mon May 06 18:29:57 2013 +0200 +++ b/src/org/tmatesoft/hg/repo/Revlog.java Mon May 06 18:53:04 2013 +0200 @@ -150,15 +150,7 @@ * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> */ public final int getRevisionIndex(Nodeid nid) throws HgRuntimeException { - int revision; - if (useRevisionLookup) { - if (revisionLookup == null) { - revisionLookup = RevisionLookup.createFor(content); - } - revision = revisionLookup.findIndex(nid); - } else { - revision = content.findRevisionIndex(nid); - } + final int revision = doFindWithCache(nid); if (revision == BAD_REVISION) { // using toString() to identify revlog. HgDataFile.toString includes path, HgManifest and HgChangelog instances // are fine with default (class name) @@ -168,6 +160,17 @@ return revision; } + private int doFindWithCache(Nodeid nid) { + if (useRevisionLookup) { + if (revisionLookup == null) { + revisionLookup = RevisionLookup.createFor(content); + } + return revisionLookup.findIndex(nid); + } else { + return content.findRevisionIndex(nid); + } + } + /** * Note, {@link Nodeid#NULL} nodeid is not reported as known in any revlog. * @@ -176,7 +179,7 @@ * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> */ public final boolean isKnown(Nodeid nodeid) throws HgRuntimeException { - final int rn = content.findRevisionIndex(nodeid); + final int rn = doFindWithCache(nodeid); if (BAD_REVISION == rn) { return false; }