[pitch] Substring performance affordances

Our general advice is to stick with String. Most APIs would be simpler and clearer just using String rather than being made generic (which itself can come at a cost), and user conversion on the way in on the few occasions that's needed isn’t much of a burden.

The exception is when your API is extremely likely to be used with substrings. The most common case for this is that it’s an API for doing string processing (such as with join or the number initializers), or when it’s very likely used with substring and conversion to string would be a major potential bottleneck (such as with set/dictionary). Also, very general algorithms that would benefit from being on StringProtocol might also be generalizable further to Sequence/Collection.


On Jun 28, 2017, at 2:41 PM, David Hart <david@hartbit.com> wrote:

Should authors use StringProtocol or String as often as possible?