perf: return ImmutableContext.EMPTY when merging two empty contexts#1973
perf: return ImmutableContext.EMPTY when merging two empty contexts#1973tobias-ibounig-dt wants to merge 1 commit into
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
ChangesImmutableContext EMPTY singleton short-circuit
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 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 #1973 +/- ##
============================================
+ Coverage 92.11% 93.17% +1.05%
- Complexity 660 665 +5
============================================
Files 59 59
Lines 1624 1626 +2
Branches 182 183 +1
============================================
+ Hits 1496 1515 +19
+ Misses 80 66 -14
+ Partials 48 45 -3
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
ImmutableContext.merge()returnsImmutableContext.EMPTYwhen boththisand the overriding context are emptyRelated Issues
None
Notes
When merging two empty contexts the previous code still allocated a new
ImmutableContext(viathis.asUnmodifiableMap()). The result is always semantically equivalent toEMPTY, so we can return the existing singleton directly.This path is not exercised by the current benchmark workload, so no allocation numbers are provided.
Follow-up Tasks
Summary by CodeRabbit
Tests
ImmutableContextwith new nested tests verifying constructor behavior and context merging scenarios, including edge cases with null and empty contexts.Performance