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: hoist char[] alloc in FsCheckPropertyTestExecutor to static SearchValues #6102

Copy link
Copy link

Description

@thomhurst
Issue body actions

Summary

FsCheckPropertyTestExecutor.cs:195 allocates a char[] on every call:

var newlineIndex = afterShrunk.IndexOfAny(['\r', '\n']);

The ['\r', '\n'] collection expression allocates a fresh array each invocation. Hoist to a static SearchValues<char>:

private static readonly SearchValues<char> _lineEndings = SearchValues.Create("\r\n");
// ...
var newlineIndex = afterShrunk.AsSpan().IndexOfAny(_lineEndings);

Impact

Low — this is an error path (only runs when a property-based test fails and a shrunk counterexample is being parsed). No measurable runtime gain in the common case. Filed for consistency with the rest of the codebase, which already uses static SearchValues<char> (e.g. MetadataFilterMatcher.cs:243, PathValidator.cs:10).

Acceptance

  • Static SearchValues<char> field added
  • No per-call array allocation
  • FsCheck tests still pass

Found during a hot-path API-modernization sweep.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance optimizationPerformance optimization

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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