Replacing string with StringSegment or ReadOnlySpan<char>. #85869
Unanswered
electricessence
asked this question in
General
Replies: 2 comments 2 replies
-
It depends on your use pattern. If the string is extracted from a long text, using Generally, the short the string lives, it's more beneficial to use span instead of copying. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Changing return/parameter types on shipped APIs is an unacceptable breaking change. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been noticing some places where it seems like
StringSegment
orReadOnlySpan<char>
would be much better suited for either parameters or return types.One example I'd like to ask about is
IConfigurationSection
https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/IConfigurationSection.csSeems like it could be beneficial to use something like
StringSegment
for.Key
or.Path
.I can imagine this as a design decision for simplicity, but it seems like a potential memory benefit would be to use something other than potential string portions of the original
string
key path.Just curious what people's thoughts are if any about this with something like
IConfigurationSection
or any other APIs/Classes where usingStringSegment
could be better.Beta Was this translation helpful? Give feedback.
All reactions