Mercurial > jhg
comparison src/org/tmatesoft/hg/util/PathPool.java @ 292:a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Wed, 14 Sep 2011 02:16:19 +0200 |
| parents | 1792b37650f2 |
| children |
comparison
equal
deleted
inserted
replaced
| 291:1483e57541ef | 292:a415fe296a50 |
|---|---|
| 34 pathRewrite = rewrite; | 34 pathRewrite = rewrite; |
| 35 cache = new WeakHashMap<String, SoftReference<Path>>(); | 35 cache = new WeakHashMap<String, SoftReference<Path>>(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 public Path path(String p) { | 38 public Path path(String p) { |
| 39 p = pathRewrite.rewrite(p); | 39 p = pathRewrite.rewrite(p).toString(); |
| 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 // TODO unify with Pool<Path> |
| 45 public Path path(Path p) { | 45 public Path path(Path p) { |
| 46 String s = pathRewrite.rewrite(p.toString()); | 46 String s = pathRewrite.rewrite(p).toString(); |
| 47 Path cached = get(s, false); | 47 Path cached = get(s, false); |
| 48 if (cached == null) { | 48 if (cached == null) { |
| 49 cache.put(s, new SoftReference<Path>(cached = p)); | 49 cache.put(s, new SoftReference<Path>(cached = p)); |
| 50 } | 50 } |
| 51 return cached; | 51 return cached; |
