-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[WIP] Shared string APIs #23050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Shared string APIs #23050
Conversation
| guard _wholeGuts.isFastUTF8 else { | ||
| // TODO: What's the right way to get the pointer for a non-fast-UTF-8 | ||
| // string here? | ||
| return try body(String(self)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me. I guess the other option would be to form a foreign string, such as a sliced NSString subclass.
| return try body(String(self)) | ||
| } | ||
|
|
||
| return try _wholeGuts.withFastUTF8 { utf8 in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't small-string correct, but small substrings will form small strings, so eager copy is even faster than using __SharedStringStorag. What we'd want to do is check for a contiguous string with a stable pointer.
Floating an early sketch of some shared
StringAPIs to improve interop code.Still some open questions, like:
ContiguousCollectioninstead of taking pointers directly (probably)cc @milseman