Skip to content

[stdlib] Mark NFD and NFC as SPI #42124

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 3 commits into from
Apr 5, 2022
Merged

[stdlib] Mark NFD and NFC as SPI #42124

merged 3 commits into from
Apr 5, 2022

Conversation

Azoy
Copy link
Contributor

@Azoy Azoy commented Mar 31, 2022

This marks the normalization utilities NFD and NFC as @_spi(Unicode) for use in _StringProcessing.

@Azoy Azoy requested review from milseman and rxwei March 31, 2022 21:59
@Azoy
Copy link
Contributor Author

Azoy commented Mar 31, 2022

@Azoy
Copy link
Contributor Author

Azoy commented Apr 4, 2022

Swap the bases to unicodeScalarView
@Azoy
Copy link
Contributor Author

Azoy commented Apr 5, 2022

@swift-ci please smoke test

@Azoy
Copy link
Contributor Author

Azoy commented Apr 5, 2022

@swift-ci please benchmark

@Azoy Azoy merged commit d78d1eb into swiftlang:main Apr 5, 2022
@Azoy Azoy deleted the spi-unicode branch April 5, 2022 19:50
Copy link
Member

@lorentey lorentey left a comment

Choose a reason for hiding this comment

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

Looks good! I added a minor note on making initializers explicit

@_spi(_Unicode)
@available(SwiftStdlib 5.7, *)
public struct Iterator {
var base: Unicode._InternalNFD<Substring>.Iterator
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@_spi(_Unicode)
@available(SwiftStdlib 5.7, *)
public struct _NFC {
let base: Substring.UnicodeScalarView
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@_spi(_Unicode)
@available(SwiftStdlib 5.7, *)
public struct _NFD {
let base: Substring.UnicodeScalarView
Copy link
Member

Choose a reason for hiding this comment

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

To avoid surprises, I recommend spelling out the memberwise initializer here. The compiler-provided one probably works fine, but it usually is a good idea to be explicit about things that might get exposed.

(E.g. I don't know for sure if the implicit initializer will be declared public or internal. internal would make more sense, but ¯\_(ツ)_/¯)

@_spi(_Unicode)
@available(SwiftStdlib 5.7, *)
public struct Iterator {
var base: Unicode._InternalNFC<Substring>.Iterator
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

Azoy added a commit to Azoy/swift that referenced this pull request May 26, 2022
Azoy added a commit that referenced this pull request May 27, 2022
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