-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[3.1] Remove erroneous drop(while:) optimization #8141
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
Conversation
|
@swift-ci please test |
|
@swift-ci Please benchmark |
Build comment file:Build failed before running benchmark. |
|
That OS X Build failed due to missing benchmark base, if I understand the log correctly? |
|
I don't imagine we have any benchmarks that would measure the impact of this change either - and even if we did they would be benchmarking an incorrect implementation. |
|
@CodaFi Sorry, but I don't understand what this is supposed to fix. The test, at least, already passes for me without having merged your change. |
|
Strange. If I run this in the REPL that ships with beta 4 (Swift 3.1, swiftlang-802.0.42.1, clang-802.0.36), I get this:
|
|
@CodaFi Sorry, I was not reading carefully enough. I see this has already been merged to master. |
|
@swift-ci Please benchmark |
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.
A better test would be:
expectEqualSequence([], Array(xs.prefix(3).drop(while: {$0 < 7})))because if the test failed, you'd get some useful information out of it.
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 can prepare a patch for master that does this. Do you want this to also land with this PR in 3.1 or does the current PR work on its own?
Build comment file:Build failed before running benchmark. |
Calling drop(while: ) after prefix() on a pure Sequence loses the prefix, because in the internal drop(while: ) override grabs the underlying base iterator from _PrefixSequence and wraps it in a _DropWhileSequence.
|
@swift-ci please test |
|
Build failed |
|
Build failed |
|
Will this land in 3.1 before final version of Xcode 8.3 ships? |
|
@dabrahams @airspeedswift Did this just miss the boat? |
Explanation: Calling
drop(while:)afterprefix()loses the prefix because the internaldrop(while:)override grabs the underlying base iterator from_PrefixSequenceand wraps it in a_DropWhileSequence. Instead, fall back toSequence's implementation.Scope: Affects consumers of the standard library that attempt to chain
Sequencetransformations that factor through_PrefixSequence.Reviewer: @airspeedswift
SR Issue: SR-4240
Risk: Very low risk; As this is an optimization, removing this causes a fallback to the correct implementation.
Testing: Regression test included in patch.
(cherry picked from commit 81968e2)