Closed SergerGood closed 1 year ago
Thanks for this PR mate. Please leave this one open. I am weighing the importance of having a new reference to System.Memory over this small fraction of memory optimizations. Will get back to this one soon.
Why not?) I added it just for netstandard2.0. Netstandard2.0 is no longer being developed and is only needed for compatibility with .Net Feamework. In order to work with Span, a special package was created for the netstandard2.0. The api for working with ReadOnlySpan of chars is implemented in the .Net as part of optimization.
For example,
implicit conversion
CA1846: Prefer AsSpan over Substring
String-like extension methods to ReadOnlySpan
What I did as part of this pull request is just the beginning) Unfortunately, until we abandon the netstandard, it will be difficult.
Calling Substring produces a copy of the extracted substring. By using AsSpan instead of Substring we can eliminate the unnecessary string allocation.
before:
after: