Skip to content

[Stdlib] Rationalize the SubSequence type of a filtered Collection. #8898

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

Closed
wants to merge 1 commit into from

Conversation

DougGregor
Copy link
Member

Address ABI FIXMEs #28, #80, #81 by making the SubSequence of a filtered
collection into be a filtered collection of the base's
SubSequence rather than a slice of this filtered collection, e.g.,
replace Slice<LazyFilterCollection<Array<T>>> with
LazyFilterCollection<ArraySlice<T>>, which allows slicing
optimizations of the base type to kick in.

While here, eliminate the vestigial type LazyFilterIndex, which was
necessary pre-Swift-3 to allow the index to move. Swift 3's indexing
model means that the movement of indices is on the collection itself,
so we no longer need LazyFilterIndex: instead, the Index type of
the lazy filtered collection is simply the Index type of the base
collection, which is a nice convenience: it means you can take indices
from a lazy wrapper around a given collection C and use them with the
collection C (and, with care, vice-versa) without jumping through
extra hoops.

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves SR-NNNN.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Address ABI FIXMEs swiftlang#28, swiftlang#80, swiftlang#81 by making the SubSequence of a filtered
collection into be a filtered collection of the base's
SubSequence rather than a slice of this filtered collection, e.g.,
replace `Slice<LazyFilterCollection<Array<T>>>` with
`LazyFilterCollection<ArraySlice<T>>`, which allows slicing
optimizations of the base type to kick in.

While here, eliminate the vestigial type `LazyFilterIndex`, which was
necessary pre-Swift-3 to allow the index to move. Swift 3's indexing
model means that the movement of indices is on the collection itself,
so we no longer need `LazyFilterIndex`: instead, the `Index` type of
the lazy filtered collection is simply the `Index` type of the base
collection, which is a nice convenience: it means you can take indices
from a lazy wrapper around a given collection C and use them with the
collection C (and, with care, vice-versa) without jumping through
extra hoops.
@DougGregor
Copy link
Member Author

Another one for @dabrahams and @airspeedswift

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

Hmm... I'm nervous about this one. The extra requirement on LazyFilter{whatever collection}

where Base.SubSequence: ${collectionForTraversal(Traversal)}

is going to break things in generic contexts. I don't think I can make this change in isolation; I think it has to follow recursive protocol constraints. Let's try to stop this merge :)

@DougGregor DougGregor closed this Apr 20, 2017
@DougGregor DougGregor deleted the filter-subsequence branch April 20, 2017 23:07
@DougGregor DougGregor restored the filter-subsequence branch April 20, 2017 23:09
@DougGregor
Copy link
Member Author

I'll still eliminate LazyFilterIndex, which was an independent change anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant