Repository navigation
Conversation
The conversion helpers built a stream pipeline, a collector accumulator and an unsized HashMap on every call, plus boxing in the lambdas: - Structure.convertValue(): list and structure branches - Structure.mapToStructure() - AbstractStructure.asObjectMap() - Value.clone() (list branch) and Value.objectToValue() (list branch) These sit on provider-facing paths: asObjectMap()/asObject() is what providers call to hand attributes to vendor backends, and it recurses per nested value. Replace them with presized loops using the existing HashMapUtils.forEntries() helper, which also avoids HashMap rehashing for larger structures. No signature, visibility or semantic changes; null handling and nested conversion are unchanged. HashMap iteration order of the presized maps can differ from the previously unsized ones, but Map ordering was never part of the contract.
tobijdc
marked this pull request as draft
October 19, 2026 19:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces the stream + custom-
Collectorconversions with plain presized loops in the four places that still used them:Structure.convertValue()(list + structure)asObjectMap()/asObject()on nested valuesStructure.mapToStructure()objectToValue()forMappayloadsAbstractStructure.asObjectMap()Value.clone()/Value.objectToValue()(list)ImmutableStructure.getValue()Each of those allocated a
Stream, a lambda, a collector accumulator and an unsizedHashMapper call. Presizing via the existingHashMapUtils.forEntries()helper also avoids rehashing.Why it matters
asObjectMap()/asObject()is how providers hand attributes to vendor backends, and it recurses per nested attribute/list element, so the per-call overhead multiplies. On a local JMH allocation benchmark (-prof gc, conversion-heavy loop callingasObjectMap()+objectToValue()on nested structures) this cut allocated instances from ~1.55M to ~1.24M for the same amount of work (-20%). That benchmark is not part of this PR to keep the diff reviewable — happy to add it as a separatesrc/testJMH module if you want it in-tree.Compatibility
HashMap) are unchanged.HashMaps can differ from the previously unsized ones.Mapordering was never part of the contract, but anyone diffing serialized output may notice.Verification
./mvnw test(JDK 17): 571 unit tests + 8 vmlens tests green, 0 checkstyle violations.Draft, for review inside the fork only.