Skip to content

Improve efficiency of map creation in DataBinder #37019

Description

@sbrannen

When DataBinder resolves a Map<String, T> constructor parameter during constructor binding, createMap() iterates all parameter names and calls createIndexedValue() — and therefore createObject() for non-simple value types — once per matching parameter name rather than once per distinct map key. For a map entry whose value type has multiple constructor parameters, each sub-field parameter name triggers a full nested object construction for the same key, with all but the last result immediately discarded.

To address this, we can probably skip createIndexedValue() when the extracted key is already present in the map, aligning createMap() with createList() and createArray(), which already avoid redundant element construction by deduplicating indexes via getIndexes() before iterating.

NOTE: This issue is assigned and therefore not suitable for community contributions.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions