Mercurial > hg4j
diff src/org/tmatesoft/hg/repo/HgManifest.java @ 414:bb278ccf9866
Pull changes from smartgit3 branch
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 21 Mar 2012 20:51:12 +0100 |
parents | 7f27122011c3 63c5a9d7ca3f |
children | ee8264d80747 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgManifest.java Wed Mar 21 20:40:28 2012 +0100 +++ b/src/org/tmatesoft/hg/repo/HgManifest.java Wed Mar 21 20:51:12 2012 +0100 @@ -52,6 +52,7 @@ */ public class HgManifest extends Revlog { private RevisionMapper revisionMap; + private EncodingHelper encodingHelper; public enum Flags { Exec, Link; // FIXME REVISIT consider REGULAR instead of null @@ -96,8 +97,9 @@ } } - /*package-local*/ HgManifest(HgRepository hgRepo, RevlogStream content) { + /*package-local*/ HgManifest(HgRepository hgRepo, RevlogStream content, EncodingHelper eh) { super(hgRepo, content); + encodingHelper = eh; } /** @@ -174,7 +176,7 @@ manifestLast = manifestFirst; manifestFirst = x; } - content.iterate(manifestFirst, manifestLast, true, new ManifestParser(inspector)); + content.iterate(manifestFirst, manifestLast, true, new ManifestParser(inspector, encodingHelper)); } /** @@ -194,7 +196,7 @@ throw new IllegalArgumentException(); } int[] manifestRevs = toManifestRevisionIndexes(revisionIndexes, inspector); - content.iterate(manifestRevs, true, new ManifestParser(inspector)); + content.iterate(manifestRevs, true, new ManifestParser(inspector, encodingHelper)); } // @@ -345,11 +347,13 @@ private int start; private final int hash, length; private Path result; + private final EncodingHelper encHelper; - public PathProxy(byte[] data, int start, int length) { + public PathProxy(byte[] data, int start, int length, EncodingHelper eh) { this.data = data; this.start = start; this.length = length; + this.encHelper = eh; // copy from String.hashCode(). In fact, not necessarily match result of String(data).hashCode // just need some nice algorithm here @@ -387,7 +391,7 @@ public Path freeze() { if (result == null) { - result = Path.create(EncodingHelper.fromManifest(data, start, length)); + result = Path.create(encHelper.fromManifest(data, start, length)); // release reference to bigger data array, make a copy of relevant part only // use original bytes, not those from String above to avoid cache misses due to different encodings byte[] d = new byte[length]; @@ -407,11 +411,13 @@ private byte[] nodeidLookupBuffer = new byte[20]; // get reassigned each time new Nodeid is added to pool private final ProgressSupport progressHelper; private IterateControlMediator iterateControl; + private final EncodingHelper encHelper; - public ManifestParser(Inspector delegate) { + public ManifestParser(Inspector delegate, EncodingHelper eh) { assert delegate != null; inspector = delegate; inspector2 = delegate instanceof Inspector2 ? (Inspector2) delegate : null; + encHelper = eh; nodeidPool = new Pool2<Nodeid>(); fnamePool = new Pool2<PathProxy>(); thisRevPool = new Pool2<Nodeid>(); @@ -435,7 +441,7 @@ int x = i; for( ; data[i] != '\n' && i < actualLen; i++) { if (fname == null && data[i] == 0) { - PathProxy px = fnamePool.unify(new PathProxy(data, x, i - x)); + PathProxy px = fnamePool.unify(new PathProxy(data, x, i - x, encHelper)); // if (cached = fnamePool.unify(px))== px then cacheMiss, else cacheHit // cpython 0..10k: hits: 15 989 152, misses: 3020 fname = px.freeze();