From 5cef9cff179bc021c3a0a075dbb167db0aed3039 Mon Sep 17 00:00:00 2001 From: Pinaki Poddar Date: Fri, 8 Jan 2010 19:40:10 +0000 Subject: [PATCH] reduce performance cost of isCacheable(). git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@897308 13f79535-47bb-0310-9956-ffa450edef68 --- .../datacache/DataCacheManagerImpl.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheManagerImpl.java b/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheManagerImpl.java index 705b157c2..b7f3fe72c 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheManagerImpl.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheManagerImpl.java @@ -160,19 +160,16 @@ public class DataCacheManagerImpl * @return TRUE or FALSE if cache mode is configured. null otherwise. */ private Boolean isCacheableByMode(ClassMetaData meta) { - switch (DataCacheMode.valueOf(_conf.getDataCacheMode())) { - case ALL: // include everything, regardless of annotation or xml configuration - return true; - case NONE: // exclude everything, regardless of annotation of xml configuration - return false; - case ENABLE_SELECTIVE: // cache only those entities which were explicitly enabled - return Boolean.TRUE.equals(meta.getCacheEnabled()); - case DISABLE_SELECTIVE: // exclude *only* the entities which are explicitly excluded - return !Boolean.FALSE.equals(meta.getCacheEnabled()); - case UNSPECIFIED: - default: // not determinable by mode - return null; - } + String mode = _conf.getDataCacheMode(); + if (DataCacheMode.ALL.toString().equalsIgnoreCase(mode)) + return true; + if (DataCacheMode.NONE.toString().equalsIgnoreCase(mode)) + return false; + if (DataCacheMode.ENABLE_SELECTIVE.toString().equalsIgnoreCase(mode)) + return Boolean.TRUE.equals(meta.getCacheEnabled()); + if (DataCacheMode.DISABLE_SELECTIVE.toString().equalsIgnoreCase(mode)) + return !Boolean.FALSE.equals(meta.getCacheEnabled()); + return null; } /**