HHH-6862 Some additional small performance improvements

This commit is contained in:
Sanne Grinovero 2011-11-30 11:35:20 +00:00
parent eb59e81bb9
commit a6b761e209
3 changed files with 11 additions and 7 deletions

View File

@ -52,7 +52,6 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
public void onAutoFlush(AutoFlushEvent event) throws HibernateException {
final EventSource source = event.getSession();
if ( flushMightBeNeeded(source) ) {
final int oldSize = source.getActionQueue().numberOfCollectionRemovals();
flushEverythingToExecutions(event);
if ( flushIsReallyNeeded(event, source) ) {
LOG.trace( "Need to execute flush" );
@ -68,6 +67,7 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
}
else {
LOG.trace( "Don't need to execute flush" );
final int oldSize = source.getActionQueue().numberOfCollectionRemovals();
source.getActionQueue().clearFromFlushNeededCheck( oldSize );
}

View File

@ -24,6 +24,7 @@
package org.hibernate.event.internal;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.event.spi.EventSource;
import org.hibernate.event.spi.FlushEvent;
import org.hibernate.event.spi.FlushEventListener;
@ -43,8 +44,9 @@ public class DefaultFlushEventListener extends AbstractFlushingEventListener imp
*/
public void onFlush(FlushEvent event) throws HibernateException {
final EventSource source = event.getSession();
if ( source.getPersistenceContext().getEntityEntries().size() > 0 ||
source.getPersistenceContext().getCollectionEntries().size() > 0 ) {
final PersistenceContext persistenceContext = source.getPersistenceContext();
if ( persistenceContext.getEntityEntries().size() > 0 ||
persistenceContext.getCollectionEntries().size() > 0 ) {
flushEverythingToExecutions(event);
performExecutions(source);

View File

@ -288,17 +288,19 @@ public class IndexBuilder {
//merge source into target
private void mergeAnnotationMap(Map<DotName, List<AnnotationInstance>> source, Map<DotName, List<AnnotationInstance>> target) {
if ( source != null && !source.isEmpty() ) {
for ( DotName annotationName : source.keySet() ) {
if ( source.get( annotationName ).isEmpty() ) {
if ( source != null ) {
for ( Map.Entry<DotName, List<AnnotationInstance>> el : source.entrySet() ) {
if ( el.getValue().isEmpty() ) {
continue;
}
DotName annotationName = el.getKey();
List<AnnotationInstance> value = el.getValue();
List<AnnotationInstance> annotationInstanceList = target.get( annotationName );
if ( annotationInstanceList == null ) {
annotationInstanceList = new ArrayList<AnnotationInstance>();
target.put( annotationName, annotationInstanceList );
}
annotationInstanceList.addAll( source.get( annotationName ) );
annotationInstanceList.addAll( value );
}
}
}