-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] Handle String's 32-bit inline representation for Span #82442
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
[stdlib] Handle String's 32-bit inline representation for Span #82442
Conversation
@swift-ci please test |
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.
Nice! (But also: ugh 😣)
return 10 | ||
#elseif _pointerBitWidth(_32) || _pointerBitWidth(_16) |
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.
Do we have platforms with 16-bit pointers? 😮
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.
They're not impossible!
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci please test linux platform |
This patch works for me... The getter's 'self' is non-copyable (no-implicit-copy). I'm not actually sure how to avoid that.
|
Alternatively, remove the ‘borrowing’ keyword from the _span getters:
|
- computed properties have an ABI impact; a function is fine here
fab3154
to
791dd4c
Compare
I circumvented the autoclosure by using the |
c19b58d
to
56aea71
Compare
56aea71
to
db664fb
Compare
@swift-ci please clean test |
String
's inline representation is currently non-contiguous on 32-bit platforms. Furthermore, that representation is baked in ABI for watchOS's 32-bit variant. This PR implements mitigations.A. For 32-bit platforms without ABI stability, we reduce the size of the inline representation to 8 UTF-8 code units (from 10).
B. For 32-bit watchOS, we add an optional property
var _span: Span<UTF8.CodeUnit>?
that returnsnil
when the representation of theString
is non-contiguous, that is when it is 9 or 10 UTF-8 code units.All platforms will get this underscored property, so that code that supports 32-bit watchOS doesn't have to be specific to it.