perf: skip iterating over empty list#1969
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
ChangesEmpty-source early exit in HookSupport
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 #1969 +/- ##
============================================
+ 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
HookSupport.addFilteredHookswhen the source collection is emptyRelated Issues
None
Notes
addFilteredHooksis called four times per flag evaluation (provider, options, client, API hooks). In the common case three of those sources are empty, but a for-each loop always callscollection.iterator()before checkinghasNext(), allocating aConcurrentLinkedQueue$ItrorArrayList$Itrunnecessarily. TheisEmpty()check short-circuits before the iterator is ever created.benchmark.txtmainmainrun:+totalAllocatedBytesrun:+totalAllocatedInstancesFollow-up Tasks
benchmark.txtafter all are appliedSummary by CodeRabbit
Release Notes
Performance
Tests