Skip to content
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-6475] String needs a method to directly access either the ascii or unicode backing storage (compatible with cocoa storage too) #3780

Closed
phausler opened this issue Nov 25, 2017 · 4 comments

Comments

@phausler
Copy link
Member

Previous ID SR-6475
Radar None
Original Reporter @phausler
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation, Standard Library
Labels Bug
Assignee @milseman
Priority Medium

md5: 160572b7782ac20bbfdcd43f71047213

Issue Description:

This implementation of conversion from String to Data is in some cases 900x faster by taking advantage of fast paths. Ideally we should not drop performance like this on the floor and offer fast access to the appropriate backing storage. (note this is just a draft/toy version of what it should be but the concept should be implemented as API or SPI).

See the example at: https://gist.github.com/phausler/c6178bc9b0764f51d3ac182a293cede5

@phausler
Copy link
Member Author

benchmarking this shows performance gains for many common usage patterns and no regression for non-common usage patterns.

@belkadan
Copy link

@milseman, is this already tracked somewhere?

@milseman
Copy link
Mannequin

milseman mannequin commented Dec 5, 2017

I don't think so.

For reference, the (highly in flux) _StringGuts branch is exploring things like an internal `withMutableASCIIStorage` or `withMutableUTF16Storage` call backs. Those currently (because they're for mutation) necessitate conversion to native storage of the appropriate width, but we could also have a read-only view that would work for any contiguous String, whether native Swift or from Cocoa.

@milseman
Copy link
Mannequin

milseman mannequin commented Apr 10, 2019

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants