Use ConcurrentHashMap to cache fetchers, on platforms that support it.

This commit is contained in:
Michael Bayne
2012-10-01 09:27:36 -07:00
parent 41eec508cb
commit 5ec24e947c
4 changed files with 30 additions and 17 deletions
@@ -11,6 +11,7 @@ import java.io.Writer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Provides <a href="http://mustache.github.com/">Mustache</a> templating services.
@@ -160,6 +161,11 @@ public class Mustache
* never be null. The fetcher will be cached and reused for future contexts for which
* {@code octx.getClass().equals(nctx.getClass()}. */
VariableFetcher createFetcher (Object ctx, String name);
/** Creates a map to be used to cache {@link VariableFetcher} instances. The GWT-compatible
* collector returns a HashMap here, but the reflection based fetcher (which only works on
* the JVM and Android, returns a concurrent hashmap. */
<K,V> Map<K,V> createFetcherCache ();
}
/**