Skip to content

[stdlib] Add withContiguousStorageIfAvailable to SubString.UTF8View #29094

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

Merged
merged 1 commit into from
Jan 10, 2020

Conversation

Lukasa
Copy link
Contributor

@Lukasa Lukasa commented Jan 9, 2020

Due to an oversight it seems that we never added a
withContigousStorageIfAvailable implementation to SubString.UTF8View,
which meant that if you sliced a String you lost the ability to get fast
access to the backing storage. There's no good reason for this
functionality to be missing, so this patch adds it in by delegating to
the Slice implementation.

Resolves SR-11999.

@Lukasa
Copy link
Contributor Author

Lukasa commented Jan 9, 2020

@swift-ci please smoke test

@Lukasa Lukasa force-pushed the cb-substring-fast-access branch from 1fa79f2 to d22b2c2 Compare January 9, 2020 12:21
@Lukasa
Copy link
Contributor Author

Lukasa commented Jan 9, 2020

@swift-ci please smoke test

@Lukasa Lukasa force-pushed the cb-substring-fast-access branch from d22b2c2 to df07967 Compare January 9, 2020 15:05
@Lukasa
Copy link
Contributor Author

Lukasa commented Jan 9, 2020

@swift-ci please smoke test

@airspeedswift airspeedswift requested a review from milseman January 9, 2020 16:19
@@ -389,6 +389,13 @@ extension Substring.UTF8View: BidirectionalCollection {
return _slice.distance(from: start, to: end)
}

@inlinable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will need either availability or emitting into the client

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(that's why the test failed)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which should it have? It seems like it should be safe to emit into the client, but you've got more practice thinking about ABI compatibility than I do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@_alwaysEmitIntoClient

Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after AEIC!

@@ -389,6 +389,13 @@ extension Substring.UTF8View: BidirectionalCollection {
return _slice.distance(from: start, to: end)
}

@inlinable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@_alwaysEmitIntoClient

Due to an oversight it seems that we never added a
withContigousStorageIfAvailable implementation to SubString.UTF8View,
which meant that if you sliced a String you lost the ability to get fast
access to the backing storage. There's no good reason for this
functionality to be missing, so this patch adds it in by delegating to
the Slice implementation.

Resolves SR-11999.
@Lukasa Lukasa force-pushed the cb-substring-fast-access branch from df07967 to 68f0816 Compare January 10, 2020 09:10
@Lukasa
Copy link
Contributor Author

Lukasa commented Jan 10, 2020

@swift-ci please smoke test

@Lukasa
Copy link
Contributor Author

Lukasa commented Jan 10, 2020

Ok, looks like we're ready to go. I don't think I have write on this repo so I don't think I can ask the CI robot to merge, though I might be wrong about that.

@milseman milseman merged commit 6209c97 into swiftlang:master Jan 10, 2020
@aschwaighofer
Copy link
Contributor

@milseman
Copy link
Member

I'm sorry, I thought this had passed full testing, not just smoke testing. Personally, I'm opposed to treating smoke testing as sufficient for merging, unless there's real crisis / time pressure. I'll revert for now and re-open with a test run

@Lukasa
Copy link
Contributor Author

Lukasa commented Jan 10, 2020

Hm, what’s this bot testing? Older binaries against newer tests and runtimes?

@milseman
Copy link
Member

@swift-ci please test

@Lukasa
Copy link
Contributor Author

Lukasa commented Jan 10, 2020

Ah, sorry, I forgot to follow up with a full test when the smoke test passed.

@milseman
Copy link
Member

Oh, if this is a backwards deployment checker bot, then maybe even that would not have catched it

@Lukasa
Copy link
Contributor Author

Lukasa commented Jan 10, 2020

The only case I can think of where this would fail is if the binary was built with a Swift before the new standard library, where it either inlined or called the old default implementation, which unconditionally returns nil.

@milseman
Copy link
Member

Right, but the test should be recompiled. What we need is a guarantee that AEIC will shadow the default implementation (from Sequence) present in an old stdlib binary.

@slavapestov, do you know if this is guaranteed?

@milseman
Copy link
Member

@Lukasa can you re-open and retry?

@Lukasa
Copy link
Contributor Author

Lukasa commented Jan 11, 2020

Re-added in #29146.

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.

4 participants