Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

perf: avoid creating closure - #4393

#4393
Merged
thomhurst merged 1 commit into
thomhurst:mainthomhurst/TUnit:mainfrom
TimothyMakkison:core_get_addTimothyMakkison/TUnit:core_get_addCopy head branch name to clipboard
Jan 13, 2026
Merged

perf: avoid creating closure#4393
thomhurst merged 1 commit into
thomhurst:mainthomhurst/TUnit:mainfrom
TimothyMakkison:core_get_addTimothyMakkison/TUnit:core_get_addCopy head branch name to clipboard

Conversation

@TimothyMakkison

@TimothyMakkison TimothyMakkison commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

Prevent closure creation for AssmeblyMetada and ClassMetadata, using GetOrAdd<TArg>(TKey, Func<TKey,TArg,TValue>, TArg)

  • Also removed an extra line

Not a massive saving probably around 100KB on TUnit.TestProject

@thomhurst

Copy link
Copy Markdown
Owner

Summary

Eliminates closure allocations in metadata caching hot paths by using the state-passing overload of ConcurrentDictionary.GetOrAdd.

Critical Issues

None found ✅

Suggestions

None - this is a clean performance optimization that aligns perfectly with TUnit's "Performance First" principle. The use of static lambdas with the state-passing GetOrAdd overload is exactly the right approach for hot path allocation reduction.

Verdict

APPROVE - No critical issues

Great optimization! This is precisely the kind of hot path improvement that benefits test discovery performance across all TUnit projects.

@thomhurst
thomhurst merged commit b6692ca into thomhurst:main Jan 13, 2026
8 of 10 checks passed
This was referenced Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.