Skip to content

refactor: use SearchValues for char-set scans in CSV export and version parsing#881

Merged
laurentiu021 merged 1 commit into
mainfrom
refactor/searchvalues-indexofany
Jun 12, 2026
Merged

refactor: use SearchValues for char-set scans in CSV export and version parsing#881
laurentiu021 merged 1 commit into
mainfrom
refactor/searchvalues-indexofany

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

Summary

Replaces two IndexOfAny(new char[] { ... }) calls — which allocate a char[] on every invocation — with hoisted static SearchValues<char> and span-based IndexOfAny (.NET 10 idiom). Byte-identical result, no per-call allocation.

Changes

  • LogsViewModel.Csv (CSV export, called per-field × per-row) — s.IndexOfAny(new[]{',','"','\n','\r'}) → static CsvSpecials = SearchValues.Create(",\"\n\r") + s.AsSpan().IndexOfAny(CsvSpecials).
  • UpdateService.ParseVersions.IndexOfAny(new[]{'-','+',' '}) → static VersionSuffixSeparators + span IndexOfAny.

Why byte-identical

SearchValues<char>.IndexOfAny over a span returns the same first-match index as string.IndexOfAny(char[]); only the allocation is removed.

Verification

  • Build: main + Tests 0 warnings / 0 errors.

refactor: → no release.

@laurentiu021 laurentiu021 merged commit 2974bf3 into main Jun 12, 2026
4 checks passed
@laurentiu021 laurentiu021 deleted the refactor/searchvalues-indexofany branch June 12, 2026 15:27
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.

1 participant