Author: manik.surtani(a)jboss.com
Date: 2008-08-14 03:40:56 -0400 (Thu, 14 Aug 2008)
New Revision: 6559
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
Log:
Construct looked up nodes lazily.
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-08-14
02:46:39 UTC (rev 6558)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-08-14
07:40:56 UTC (rev 6559)
@@ -5,6 +5,7 @@
import org.jboss.cache.transaction.MVCCTransactionContext;
import org.jboss.cache.transaction.TransactionContext;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -16,7 +17,7 @@
*/
public class MVCCInvocationContext extends AbstractInvocationContext
{
- private final Map<Fqn, NodeSPI> lookedUpNodes = new HashMap<Fqn,
NodeSPI>(4);
+ private Map<Fqn, NodeSPI> lookedUpNodes = null;
private MVCCTransactionContext mvccTCtx;
@Override
@@ -38,7 +39,7 @@
public NodeSPI lookUpNode(Fqn fqn)
{
if (mvccTCtx != null) return mvccTCtx.lookUpNode(fqn);
- return lookedUpNodes.get(fqn);
+ return lookedUpNodes == null ? null : lookedUpNodes.get(fqn);
}
/**
@@ -55,7 +56,10 @@
if (mvccTCtx != null)
mvccTCtx.putLookedUpNode(f, n);
else
+ {
+ if (lookedUpNodes == null) lookedUpNodes = new HashMap<Fqn, NodeSPI>(4);
lookedUpNodes.put(f, n);
+ }
}
/**
@@ -69,7 +73,8 @@
// if (mvccTCtx != null)
// mvccTCtx.clearLookedUpNodes();
// else
- lookedUpNodes.clear();
+
+ if (lookedUpNodes != null) lookedUpNodes.clear();
}
/**
@@ -80,10 +85,11 @@
*
* @return a map of looked up nodes.
*/
+ @SuppressWarnings("unchecked")
public Map<Fqn, NodeSPI> getLookedUpNodes()
{
if (mvccTCtx != null) return mvccTCtx.getLookedUpNodes();
- return lookedUpNodes;
+ return (Map<Fqn, NodeSPI>) (lookedUpNodes == null ? Collections.emptyMap() :
lookedUpNodes);
}
@Override
Show replies by date