comparison src/org/tmatesoft/hg/repo/HgManifest.java @ 304:85b8efde5586

Use memory-friendly set implementation to canonicalize filenames and nodeids
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 21 Sep 2011 18:26:16 +0200
parents 650b45d290b1
children f9f3e9b67ccc
comparison
equal deleted inserted replaced
303:2ffcbf360fd5 304:85b8efde5586
27 import org.tmatesoft.hg.core.Nodeid; 27 import org.tmatesoft.hg.core.Nodeid;
28 import org.tmatesoft.hg.internal.DataAccess; 28 import org.tmatesoft.hg.internal.DataAccess;
29 import org.tmatesoft.hg.internal.DigestHelper; 29 import org.tmatesoft.hg.internal.DigestHelper;
30 import org.tmatesoft.hg.internal.Experimental; 30 import org.tmatesoft.hg.internal.Experimental;
31 import org.tmatesoft.hg.internal.Lifecycle; 31 import org.tmatesoft.hg.internal.Lifecycle;
32 import org.tmatesoft.hg.internal.Pool; 32 import org.tmatesoft.hg.internal.Pool2;
33 import org.tmatesoft.hg.internal.RevlogStream; 33 import org.tmatesoft.hg.internal.RevlogStream;
34 import org.tmatesoft.hg.util.Path; 34 import org.tmatesoft.hg.util.Path;
35 35
36 36
37 /** 37 /**
279 279
280 private static class ManifestParser implements RevlogStream.Inspector { 280 private static class ManifestParser implements RevlogStream.Inspector {
281 private boolean gtg = true; // good to go 281 private boolean gtg = true; // good to go
282 private final Inspector inspector; 282 private final Inspector inspector;
283 private final Inspector2 inspector2; 283 private final Inspector2 inspector2;
284 private Pool<Nodeid> nodeidPool, thisRevPool; 284 private Pool2<Nodeid> nodeidPool, thisRevPool;
285 private final Pool<PathProxy> fnamePool; 285 private final Pool2<PathProxy> fnamePool;
286 private byte[] nodeidLookupBuffer = new byte[20]; // get reassigned each time new Nodeid is added to pool 286 private byte[] nodeidLookupBuffer = new byte[20]; // get reassigned each time new Nodeid is added to pool
287 287
288 public ManifestParser(Inspector delegate) { 288 public ManifestParser(Inspector delegate) {
289 assert delegate != null; 289 assert delegate != null;
290 inspector = delegate; 290 inspector = delegate;
291 inspector2 = delegate instanceof Inspector2 ? (Inspector2) delegate : null; 291 inspector2 = delegate instanceof Inspector2 ? (Inspector2) delegate : null;
292 nodeidPool = new Pool<Nodeid>(); 292 nodeidPool = new Pool2<Nodeid>();
293 fnamePool = new Pool<PathProxy>(); 293 fnamePool = new Pool2<PathProxy>();
294 thisRevPool = new Pool<Nodeid>(); 294 thisRevPool = new Pool2<Nodeid>();
295 } 295 }
296 296
297 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess da) { 297 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess da) {
298 if (!gtg) { 298 if (!gtg) {
299 return; 299 return;
352 // 352 //
353 // keep only actual file revisions, found at this version 353 // keep only actual file revisions, found at this version
354 // (next manifest is likely to refer to most of them, although in specific cases 354 // (next manifest is likely to refer to most of them, although in specific cases
355 // like commit in another branch a lot may be useless) 355 // like commit in another branch a lot may be useless)
356 nodeidPool.clear(); 356 nodeidPool.clear();
357 Pool<Nodeid> t = nodeidPool; 357 Pool2<Nodeid> t = nodeidPool;
358 nodeidPool = thisRevPool; 358 nodeidPool = thisRevPool;
359 thisRevPool = t; 359 thisRevPool = t;
360 } catch (IOException ex) { 360 } catch (IOException ex) {
361 throw new HgBadStateException(ex); 361 throw new HgBadStateException(ex);
362 } 362 }