String.Intern currently accepts a string parameter. When processing a ReadOnlySpan<char> it would be nice to be able to intern a string without a necessary string allocation upfront. This would be especially useful for strings that would be used frequently.
For this reason I would request the following overloads added to string:
public class String
{
// Existing APIs
public static string Intern(string str);
public static string? IsInterned(string str);
// New APIs
public static string Intern(ReadOnlySpan<char> str);
public static bool IsInterned(ReadOnlySpan<char> str);
}
String.Intern currently accepts a string parameter. When processing a
ReadOnlySpan<char>it would be nice to be able to intern a string without a necessary string allocation upfront. This would be especially useful for strings that would be used frequently.For this reason I would request the following overloads added to string: