perf: skip ImmutableMetadata allocation when builder has no entries#1971
Conversation
Signed-off-by: Tobias Ibounig <tobias.ibounig@dynatrace.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesImmutableMetadata empty-singleton optimization
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1971 +/- ##
============================================
+ Coverage 92.11% 93.11% +0.99%
- Complexity 660 664 +4
============================================
Files 59 59
Lines 1624 1626 +2
Branches 182 183 +1
============================================
+ Hits 1496 1514 +18
+ Misses 80 66 -14
+ Partials 48 46 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|



This PR
ImmutableMetadata.build()returnsEMPTYsingleton when the builder's metadata map is emptyImmutableMetadata.asUnmodifiableMap()returnsCollections.emptyMap()singleton when metadata is emptyRelated Issues
None
Notes
ImmutableMetadata.builder().build()is the@Builder.DefaultforProviderEvaluation.flagMetadata, so every flag evaluation without explicit metadata allocated a throwawayImmutableMetadatabacked by an emptyHashMap. ReturningEMPTYis safe —ImmutableMetadatahas no mutation methods.asUnmodifiableMap()now returns the JDKCollections.emptyMap()singleton for empty metadata, avoiding theUnmodifiableMapwrapper allocation.run:+totalAllocatedInstancesrun:+totalAllocatedBytesFollow-up Tasks
benchmark.txtafter all are appliedSummary by CodeRabbit
Bug Fixes
Tests