Skip to content

Commit

Permalink
HHH-9001 Unnecessary Stack object being allocated in org.hibernate.en…
Browse files Browse the repository at this point in the history
…gine.internal.Cascade
  • Loading branch information
Sanne authored and brmeyer committed Feb 26, 2014
1 parent 8f52c61 commit 7b3f140
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Expand Up @@ -27,7 +27,6 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Stack;

import org.hibernate.HibernateException;
import org.hibernate.collection.spi.PersistentCollection;
Expand Down Expand Up @@ -59,6 +58,8 @@
*/
public final class Cascade {

private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Cascade.class.getName());

/**
* A cascade point that occurs just after the insertion of the parent entity and
* just before deletion
Expand Down Expand Up @@ -102,9 +103,7 @@ public final class Cascade {
*/
public static final int BEFORE_MERGE = 0;

private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Cascade.class.getName());


private int componentPathStackDepth = 0;
private int cascadeTo;
private EventSource eventSource;
private CascadingAction action;
Expand Down Expand Up @@ -230,7 +229,7 @@ else if ( type.isComponentType() ) {
final EntityEntry entry = eventSource.getPersistenceContext().getEntry( parent );
if ( entry != null && entry.getStatus() != Status.SAVING ) {
final Object loadedValue;
if ( componentPathStack.isEmpty() ) {
if ( componentPathStackDepth == 0 ) {
// association defined on entity
loadedValue = entry.getLoadedValue( propertyName );
}
Expand Down Expand Up @@ -298,8 +297,6 @@ private boolean isLogicalOneToOne(Type type) {
return type.isEntityType() && ( (EntityType) type ).isLogicalOneToOne();
}

private Stack componentPathStack = new Stack();

private boolean cascadeAssociationNow(AssociationType associationType) {
return associationType.getForeignKeyDirection().cascadeNow(cascadeTo);
}
Expand All @@ -310,7 +307,7 @@ private void cascadeComponent(
final CompositeType componentType,
final String componentPropertyName,
final Object anything) {
componentPathStack.push( componentPropertyName );
componentPathStackDepth++;
Object[] children = componentType.getPropertyValues( child, eventSource );
Type[] types = componentType.getSubtypes();
for ( int i=0; i<types.length; i++ ) {
Expand All @@ -328,7 +325,7 @@ private void cascadeComponent(
);
}
}
componentPathStack.pop();
componentPathStackDepth--;
}

private void cascadeAssociation(
Expand Down
Expand Up @@ -25,7 +25,6 @@
package org.hibernate.hql.internal.ast.util;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Stack;

import antlr.collections.AST;

Expand Down

0 comments on commit 7b3f140

Please sign in to comment.