Skip to content

Commit fe5bb51

Browse files
herothedayodrotbohm
authored andcommitted
DATAMONGO-1449 - Switched to foreach loop in collection handling of MappingMongoConverter.
This should result in minor to moderate performance improvement for iteration on Collections/Arrays during DBObject to object mapping. Original pull request: #368.
1 parent c84bfbc commit fe5bb51

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,9 +901,7 @@ private Object readCollectionOrArray(TypeInformation<?> targetType, BasicDBList
901901
Collection<Object> items = targetType.getType().isArray() ? new ArrayList<Object>()
902902
: CollectionFactory.createCollection(collectionType, rawComponentType, sourceValue.size());
903903

904-
for (int i = 0; i < sourceValue.size(); i++) {
905-
906-
Object dbObjItem = sourceValue.get(i);
904+
for (Object dbObjItem : sourceValue) {
907905

908906
if (dbObjItem instanceof DBRef) {
909907
items.add(DBRef.class.equals(rawComponentType) ? dbObjItem

0 commit comments

Comments
 (0)