Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 5d2d09862 -> f53e4d8c7
Support config the default size of adapter cache Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/f53e4d8c Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/f53e4d8c Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/f53e4d8c Branch: refs/heads/GROOVY_2_6_X Commit: f53e4d8c7233dd364f996c101fa1ca4d4186b6d2 Parents: 5d2d098 Author: sunlan <[email protected]> Authored: Wed Jan 3 17:26:00 2018 +0800 Committer: sunlan <[email protected]> Committed: Wed Jan 3 18:47:35 2018 +0800 ---------------------------------------------------------------------- src/main/groovy/groovy/util/ProxyGenerator.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/f53e4d8c/src/main/groovy/groovy/util/ProxyGenerator.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/ProxyGenerator.java b/src/main/groovy/groovy/util/ProxyGenerator.java index da12b97..ff4c1d5 100644 --- a/src/main/groovy/groovy/util/ProxyGenerator.java +++ b/src/main/groovy/groovy/util/ProxyGenerator.java @@ -55,8 +55,6 @@ public class ProxyGenerator { private static final Map<Object,Object> EMPTY_CLOSURE_MAP = Collections.emptyMap(); private static final Set<String> EMPTY_KEYSET = Collections.emptySet(); - public static final ProxyGenerator INSTANCE = new ProxyGenerator(); - static { // wrap the standard MetaClass with the delegate setMetaClass(GroovySystem.getMetaClassRegistry().getMetaClass(ProxyGenerator.class)); @@ -66,13 +64,17 @@ public class ProxyGenerator { private boolean debug = false; private boolean emptyMethods = false; + private static final Integer GROOVY_ADAPTER_CACHE_DEFAULT_SIZE = Integer.getInteger("groovy.adapter.cache.default.size", 16); + + public static final ProxyGenerator INSTANCE = new ProxyGenerator(); // TODO should we make ProxyGenerator singleton? + /** * The adapter cache is used to cache proxy classes. When, for example, a call like: * map as MyClass is found, then a lookup is made into the cache to find if a suitable * adapter already exists. If so, then the class is reused, instead of generating a * new class. */ - private final LRUCache adapterCache = new LRUCache(16); + private final LRUCache adapterCache = new LRUCache(GROOVY_ADAPTER_CACHE_DEFAULT_SIZE); public boolean getDebug() { return debug;
