comparison src/org/tmatesoft/hg/util/PathPool.java @ 231:1792b37650f2

Introduced access to conflict resolution information (merge state)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 01 Jun 2011 05:44:25 +0200
parents 8248aae33f7d
children a415fe296a50
comparison
equal deleted inserted replaced
230:0dd9da7489dc 231:1792b37650f2
39 p = pathRewrite.rewrite(p); 39 p = pathRewrite.rewrite(p);
40 return get(p, true); 40 return get(p, true);
41 } 41 }
42 42
43 // pipes path object through cache to reuse instance, if possible 43 // pipes path object through cache to reuse instance, if possible
44 // TODO unify with Pool<Path>
44 public Path path(Path p) { 45 public Path path(Path p) {
45 String s = pathRewrite.rewrite(p.toString()); 46 String s = pathRewrite.rewrite(p.toString());
46 Path cached = get(s, false); 47 Path cached = get(s, false);
47 if (cached == null) { 48 if (cached == null) {
48 cache.put(s, new SoftReference<Path>(cached = p)); 49 cache.put(s, new SoftReference<Path>(cached = p));
61 return get(path.subSequence(0, i+1).toString(), true); 62 return get(path.subSequence(0, i+1).toString(), true);
62 } 63 }
63 } 64 }
64 return get("", true); 65 return get("", true);
65 } 66 }
67
68 // invoke when path pool is no longer in use, to ease gc work
69 public void clear() {
70 cache.clear();
71 }
66 72
67 private Path get(String p, boolean create) { 73 private Path get(String p, boolean create) {
68 SoftReference<Path> sr = cache.get(p); 74 SoftReference<Path> sr = cache.get(p);
69 Path path = sr == null ? null : sr.get(); 75 Path path = sr == null ? null : sr.get();
70 if (path == null) { 76 if (path == null) {