Skip to content

Commit bd41123

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 185b85b commit bd41123

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
@@ -897,9 +897,7 @@ private Object readCollectionOrArray(TypeInformation<?> targetType, BasicDBList
897897
Collection<Object> items = targetType.getType().isArray() ? new ArrayList<Object>()
898898
: CollectionFactory.createCollection(collectionType, rawComponentType, sourceValue.size());
899899

900-
for (int i = 0; i < sourceValue.size(); i++) {
901-
902-
Object dbObjItem = sourceValue.get(i);
900+
for (Object dbObjItem : sourceValue) {
903901

904902
if (dbObjItem instanceof DBRef) {
905903
items.add(

0 commit comments

Comments
 (0)