From 582cfc504aaa7680bc63bc5b88511cd6feb84eee Mon Sep 17 00:00:00 2001 From: "Richard G. Curtis" Date: Mon, 18 Mar 2013 21:43:26 +0000 Subject: [PATCH] OPENJPA-2353: Reduce object allocations in DetachManagerLite. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1458026 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/openjpa/kernel/DetachManagerLite.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManagerLite.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManagerLite.java index b4e60d5ab..eac31d491 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManagerLite.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManagerLite.java @@ -32,9 +32,11 @@ import org.apache.openjpa.util.Proxy; */ public class DetachManagerLite { private final boolean _detachProxies; + private final TransferFieldManager _tsm; - public DetachManagerLite(OpenJPAConfiguration conf) { + public DetachManagerLite(OpenJPAConfiguration conf) { _detachProxies = conf.getDetachStateInstance().getDetachProxyFields(); + _tsm = new TransferFieldManager(); } /** @@ -44,7 +46,7 @@ public class DetachManagerLite { * The StateManagers to be detached. */ public void detachAll(Collection states) { - TransferFieldManager fm = new TransferFieldManager(); + for (StateManagerImpl sm : states) { ClassMetaData cmd = sm.getMetaData(); if (sm.isPersistent() && cmd.isDetachable()) { @@ -54,7 +56,7 @@ public class DetachManagerLite { BitSet loaded = sm.getLoaded(); for (FieldMetaData fmd : cmd.getProxyFields()) { if (loaded.get(fmd.getIndex())) { - detachProxyField(fmd, pc, sm, fm); + detachProxyField(fmd, pc, sm, _tsm); } } pc.pcReplaceStateManager(null);