-
-
Notifications
You must be signed in to change notification settings - Fork 108
perf: optimize GetEligibleEventObjects with single-allocation approach #4307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
SummaryPerformance optimization that eliminates triple allocation in Critical IssuesNone found ✅ AnalysisThis PR implements solid performance optimizations in hot-path code (test discovery/execution): TestContextExtensions.cs
EventReceiverOrchestrator.cs
HookExecutor.cs
Performance characteristicsAll changes follow TUnit's "Performance First" principle (CLAUDE.md rule #4):
Code quality
Verdict✅ APPROVE - Well-executed performance optimization with no critical issues |
Replaces the previous implementation that used: - List allocation + ToArray() + OfType<object>().ToArray() - Three separate allocations for the same data New implementation: - Counts non-null items first to determine exact array size - Single array allocation with exact size needed - Direct population without intermediate collections - Eliminates LINQ overhead from OfType<object>() Co-Authored-By: Claude Opus 4.5 <[email protected]>
4187b28 to
6fb1790
Compare
SummaryEliminates triple allocation in hot-path event object collection by counting non-nulls first, then allocating a single exact-sized array. Critical IssuesNone found ✅ AnalysisThis PR optimizes Allocation Reduction
Code Quality
TUnit Rule Compliance
Minor ObservationThe manual loop approach in counting helpers is correct for avoiding LINQ overhead, consistent with TUnit's performance-first principle. Previous Review StatusAuthor (thomhurst) already approved with same findings. Verdict✅ APPROVE - Clean performance optimization with no critical issues |
Summary
GetEligibleEventObjects(List + ToArray + OfType.ToArray)OfType<object>()Previous implementation
New implementation
Test plan
🤖 Generated with Claude Code