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
[SR-10094] withContiguousStorageIfAvailable(_:) needs documentation #52496
Comments
Comment by Kristaps Grinbergs (JIRA) I submitted this in PR #25301 |
Comment by Kristaps Grinbergs (JIRA) What would be the right approach with this issue as my PR is merged? Close or resolve the issue? |
The person who fixes it marks it Resolved; the person who reported it gets to Close it if they're satisfied. |
Speaking as the person who reported this, after looking at the PR, that's good progress but I'm not satisfied. In particular, the second paragraph of this bug is talking about |
- We can safely state that when contiguous storage does not exist, none will get allocated. Addresses apple#52496
In practice, no type in the standard library makes an allocation in order to provide a contiguous buffer through Should we improve the documentation to clearly state a performance expectation for |
Additional Detail from JIRA
md5: e077a76eeecc3dc024d0dd80f9cd4f60
Issue Description:
SE-0237 introduces
Sequence.withContiguousStorageIfAvailable(_:)
andCollection.withContiguousMutableStorageIfAvailable(_:)
. Neither the protocol methods nor any of the concrete implementations have documentation, and they need it.Of special note is
String.UTF8View.withContiguousStorageIfAvailable(_:)
. SE-0237 documents thatwithContiguousStorageIfAvailable(_:)
may allocate contiguous storage if it doesn't yet exist. The current implementation ofString.UTF8View.withContiguousStorageIfAvailable(_:)
checks if theString
is already backed by UTF-8 and returnsnil
if not. Based on the proposal description, this implementation could instead allocate a temporary buffer that copies the bridged string to UTF-8. The current behavior is preferable, but as an external developer I feel like I can't rely on it until it's documented, so this particular implementation should explicitly document that it returnsnil
if the string isn't already backed by UTF-8.The text was updated successfully, but these errors were encountered: