Skip to content

Conversation

@TimothyMakkison
Copy link
Contributor

@TimothyMakkison TimothyMakkison commented Jan 10, 2026

Use GetAlternateLookup to avoid allocaing a string via SubString.

Edit: use preprocessor directive, apparently you can't polyfill GetAlternativeLookup

Small improvement saves around 200KB

@thomhurst
Copy link
Owner

Summary

Replaces Substring allocation with GetAlternateLookup on .NET 9+ in test discovery hot path, saving approximately 200KB.

Critical Issues

None found - approved

Suggestions

None - this is a well-executed performance optimization that targets a hot path per Rule 4, uses preprocessor directive for backward compatibility, maintains semantic equivalence with zero-allocation lookup, and doesn't require snapshot updates.

The use of GetAlternateLookup with ReadOnlySpan is the correct modern approach for span-based HashSet lookups in .NET 9+.

Verdict

APPROVE - Clean performance win with no downsides

@thomhurst thomhurst merged commit 2809ade into thomhurst:main Jan 10, 2026
9 of 10 checks passed
This was referenced Jan 11, 2026
This was referenced Jan 12, 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