Skip to content

perf(Core/SourceLength): Change Substring to Span#870

Merged
knocte merged 1 commit into
fsprojects:masterfrom
Numpsy:multilinew_strip_span
Jul 15, 2026
Merged

perf(Core/SourceLength): Change Substring to Span#870
knocte merged 1 commit into
fsprojects:masterfrom
Numpsy:multilinew_strip_span

Conversation

@Numpsy

@Numpsy Numpsy commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

I was looking at this when I opened #869 - leaving it as a draft for now due to that

Creating two substrings and then joining them allocates 3 strings, but creating two spans and concatenating those only allocates one, which can be a substantial saving on large files.

Running the benchmarks with the extended set of 'self check' rules enabled gives me -

Before:

Method Mean Error StdDev Gen0 Gen1 Gen2 Allocated
LintParsedFile 1.467 s 0.0287 s 0.0282 s 36000.0000 12000.0000 3000.0000 622 MB

After:

Method Mean Error StdDev Gen0 Gen1 Gen2 Allocated
LintParsedFile 1.433 s 0.0085 s 0.0076 s 35000.0000 11000.0000 2000.0000 588.75 MB

@knocte

knocte commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

LGTM; just respect the 50char max limit for commit msg title (otherwise it overflows into next line), e.g. perf(Core/SourceLength): spans over substrings, thanks

Creating two substrings and then joining them allocates 3 strings,
but creating two spans and concatenating those only allocates
one, which can be a substantial saving on large files.

Running the benchmarks with the extended set of 'self check'
rules enabled gives me -

Before:
| Method         | Mean    | Error    | StdDev   | Gen0       | Gen1       | Gen2      | Allocated |
|--------------- |--------:|---------:|---------:|-----------:|-----------:|----------:|----------:|
| LintParsedFile | 1.467 s | 0.0287 s | 0.0282 s | 36000.0000 | 12000.0000 | 3000.0000 |    622 MB |

After:
| Method         | Mean    | Error    | StdDev   | Gen0       | Gen1       | Gen2      | Allocated |
|--------------- |--------:|---------:|---------:|-----------:|-----------:|----------:|----------:|
| LintParsedFile | 1.433 s | 0.0085 s | 0.0076 s | 35000.0000 | 11000.0000 | 2000.0000 | 588.75 MB |
@Numpsy
Numpsy force-pushed the multilinew_strip_span branch from e07a4ed to bacd5ea Compare July 14, 2026 20:48
@Numpsy Numpsy changed the title perf(Core/SourceLength): Use spans instead of substrings in stripMultilineComments perf(Core/SourceLength): Change Substring to Span Jul 14, 2026
@Numpsy
Numpsy marked this pull request as ready for review July 14, 2026 21:11
@knocte
knocte merged commit 8c6e205 into fsprojects:master Jul 15, 2026
8 checks passed
@Numpsy
Numpsy deleted the multilinew_strip_span branch July 15, 2026 19:29
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