-
Notifications
You must be signed in to change notification settings - Fork 10.5k
stdlib: make RangeReplaceableCollection.SubSequence a RangeReplaceableCollection #4825
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: make RangeReplaceableCollection.SubSequence a RangeReplaceableCollection #4825
Conversation
27bde6d
to
6d74d44
Compare
get { | ||
return MutableRandomAccessSlice(base: self, bounds: bounds) | ||
return MutableRangeReplaceableRandomAccessSlice(base: self, bounds: bounds) |
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 you have an additional test case so we can verify this is the right type in the future?
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.
The newly-added protocol constraint ensures that the slice type conforms to RangeReplaceableCollection
. I'll try to add a direct test, but I don't have access to a macOS machine.
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.
Alternatively, you can use Data
as Data
's slice type (I was just making a minimal change). It would make sense if constructing a Data
pointing to other Data
's storage is O(1) (I don't know if it is).
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.
I added the tests.
560f122
to
c0ee982
Compare
RangeReplaceableCollection.SubSequence should be a RangeReplaceableCollection. Data implements RangeReplaceableCollection, but sets SubSequence to MutableRandomAccessSlice that is not a RangeReplaceableCollection. This commit changes Foundation.Data.SubSequence to MutableRangeReplaceableRandomAccessSlice. Fixes rdar://problem/28330713.
…much faster than the default
…eCollection Fixes rdar://problem/28330668.
d0da4f5
to
25378de
Compare
@parkera Note that I'm also changing |
@parkera Equivalent PR for corelibs-foundation: swiftlang/swift-corelibs-foundation#646 |
Test with: swiftlang/swift-corelibs-foundation#646 @swift-ci Please smoke test |
Test with: swiftlang/swift-corelibs-foundation#646 @swift-ci Please smoke test Linux platform |
@parkera OK to merge this now? |
Please note that this PR and swiftlang/swift-corelibs-foundation#646 should be merged simultaneously. |
@dabrahams ok -- thanks for fixing this @gribozavr |
This change makes RangeReplaceableCollection.SubSequence a RangeReplaceableCollection, and fixes Foundation.Data that did not conform to this requirement.
Fixes:
rdar://problem/28330668
rdar://problem/28330713