-
-
Notifications
You must be signed in to change notification settings - Fork 108
perf: remove closures in GetOrAdd
#4479
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 to eliminate closure allocations in Critical IssuesNone found ✅ SuggestionsConsider applying the same optimization to While I understand the trimmer analyzer concern mentioned in the PR description, the pattern should be safe to apply to The change would look like: return _classContexts.GetOrAdd(classType, static (type, provider) =>
new ClassHookContext(provider.GetOrCreateAssemblyContext(type.Assembly))
{
ClassType = type
}, this);The trimmer warning (if any) can likely be suppressed with Performance verification: These changes touch hot paths (ContextProvider.cs:66, ObjectInitializer.cs:108). Have you benchmarked the allocation reduction? While the changes look correct, it would be valuable to quantify the improvement given TUnit's performance-first mandate. Verdict✅ APPROVE - Clean performance optimization with no critical issues |
Use
GetOrAddoverload and pass state in to avoid creatingFuncor closuresGetOrCreateClassContext, but the trimmer analyser doesn't like this. I'd assume it's safe to allow this, but I'm not familiar with AOT requirements