OPENJPA-2353: Reduce object allocations in DetachManagerLite.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1458026 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Richard G. Curtis 2013-03-18 21:43:26 +00:00
parent 1febbf7b16
commit 582cfc504a
1 changed files with 5 additions and 3 deletions

View File

@ -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) {
_detachProxies = conf.getDetachStateInstance().getDetachProxyFields();
_tsm = new TransferFieldManager();
}
/**
@ -44,7 +46,7 @@ public class DetachManagerLite {
* The StateManagers to be detached.
*/
public void detachAll(Collection<StateManagerImpl> 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);