Skip to content

Comments

Use SourceText.ToString directly instead of GetSubTextString extension method.#12659

Merged
ToddGrun merged 2 commits intomainfrom
dev/toddgrun/Remove_SourceText.GetSubTextString_ExtensionMethod
Jan 8, 2026
Merged

Use SourceText.ToString directly instead of GetSubTextString extension method.#12659
ToddGrun merged 2 commits intomainfrom
dev/toddgrun/Remove_SourceText.GetSubTextString_ExtensionMethod

Conversation

@ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented Jan 8, 2026

The SourceText.ToString implementation is the standard way to get a piece of text from a SourceText. Switching code to use SourceText.ToString instead of our GetSubTextString extension method is likely a perf improvement on net core (not adding potentially large arrays to a pool), and likely a perf wash on net std (the ToString call does an extra copy of the data, but again won't add large arrays to a pool)

This is the fallout from a comment in a recent PR noticing that we were using ToString/GetSubTextString interchangeably throughout the codebase.

…n method.

The ToString implementation is the standard way to get a piece of text from a SourceText. This is likely a perf improvement on net core (not adding potentially large arrays to a pool), and likely a perf wash on net std (the ToString call does an extra copy of the data, but again won't add large arrays to a pool)
@ToddGrun ToddGrun requested a review from a team as a code owner January 8, 2026 03:42
@ToddGrun ToddGrun merged commit a7e56b6 into main Jan 8, 2026
10 checks passed
@ToddGrun ToddGrun deleted the dev/toddgrun/Remove_SourceText.GetSubTextString_ExtensionMethod branch January 8, 2026 05:04
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jan 8, 2026
@davidwengier davidwengier modified the milestones: Next, 18.4 Jan 27, 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