HHH-6862 Switch to use Iterable from Iterator in IdentityMap helpers

This commit is contained in:
Sanne Grinovero 2011-11-29 18:55:04 +00:00 committed by Strong Liu
parent aa4954be8b
commit ad3afa4b7d
3 changed files with 11 additions and 18 deletions

View File

@ -1162,9 +1162,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
//not found in case, proceed
// iterate all the entities currently associated with the persistence context.
Iterator<Entry<Object,EntityEntry>> entities = IdentityMap.entriesIterator( entityEntries );
while ( entities.hasNext() ) {
final Map.Entry<Object,EntityEntry> me = entities.next();
for ( Entry<Object,EntityEntry> me : IdentityMap.entriesIterable( entityEntries ) ) {
final EntityEntry entityEntry = me.getValue();
// does this entity entry pertain to the entity persister in which we are interested (owner)?
if ( persister.isSubclassEntityName( entityEntry.getEntityName() ) ) {
@ -1286,9 +1284,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
//Not found in cache, proceed
Iterator<Entry<Object,EntityEntry>> entities = IdentityMap.entriesIterator( entityEntries );
while ( entities.hasNext() ) {
Map.Entry<Object,EntityEntry> me = entities.next();
for ( Entry<Object, EntityEntry> me : IdentityMap.entriesIterable( entityEntries ) ) {
EntityEntry ee = me.getValue();
if ( persister.isSubclassEntityName( ee.getEntityName() ) ) {
Object instance = me.getKey();

View File

@ -186,10 +186,9 @@ public abstract class AbstractFlushingEventListener implements Serializable {
LOG.debug( "Dirty checking collections" );
Iterator<Map.Entry<PersistentCollection,CollectionEntry>> entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() );
while ( entriesIterator.hasNext() ) {
Map.Entry<PersistentCollection,CollectionEntry> e = entriesIterator.next();
e.getValue().preFlush( e.getKey() );
for ( Map.Entry<PersistentCollection,CollectionEntry> entry :
IdentityMap.entriesIterable( (Map<PersistentCollection,CollectionEntry>) persistenceContext.getCollectionEntries() )) {
entry.getValue().preFlush( entry.getKey() );
}
}
@ -246,9 +245,8 @@ public abstract class AbstractFlushingEventListener implements Serializable {
LOG.trace( "Processing unreferenced collections" );
Iterator<Map.Entry<PersistentCollection,CollectionEntry>> entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() );
while ( entriesIterator.hasNext() ) {
Map.Entry<PersistentCollection,CollectionEntry> me = entriesIterator.next();
for ( Map.Entry<PersistentCollection,CollectionEntry> me :
IdentityMap.entriesIterable( (Map<PersistentCollection,CollectionEntry>) persistenceContext.getCollectionEntries() )) {
CollectionEntry ce = me.getValue();
if ( !ce.isReached() && !ce.isIgnore() ) {
Collections.processUnreachableCollection( me.getKey(), session );
@ -259,10 +257,9 @@ public abstract class AbstractFlushingEventListener implements Serializable {
LOG.trace( "Scheduling collection removes/(re)creates/updates" );
entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() );
ActionQueue actionQueue = session.getActionQueue();
while ( entriesIterator.hasNext() ) {
Map.Entry<PersistentCollection,CollectionEntry> me = entriesIterator.next();
for ( Map.Entry<PersistentCollection,CollectionEntry> me :
IdentityMap.entriesIterable( (Map<PersistentCollection,CollectionEntry>) persistenceContext.getCollectionEntries() )) {
PersistentCollection coll = me.getKey();
CollectionEntry ce = me.getValue();

View File

@ -90,8 +90,8 @@ public final class IdentityMap<K,V> implements Map<K,V> {
return ( (IdentityMap<K,V>) map ).entryArray();
}
public static <K,V> Iterator<Map.Entry<K,V>> entriesIterator(Map<K,V> map) {
return ( (IdentityMap<K,V>) map ).entryList().iterator();
public static <K,V> Iterable<Map.Entry<K,V>> entriesIterable(Map<K,V> map) {
return ( (IdentityMap<K,V>) map ).entryList();
}
public static <K,V> Iterator<K> keyIterator(Map<K,V> map) {