Skip to content

UTF8Span #78531

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 9 commits into from
Apr 11, 2025
Merged

UTF8Span #78531

merged 9 commits into from
Apr 11, 2025

Conversation

milseman
Copy link
Member

@milseman milseman commented Jan 9, 2025

CI Toolchain status

Current toolchain: https://ci.swift.org/job/swift-PR-toolchain-macos/1865/artifact/branch-main/swift-PR-78531-1865-osx.tar.gz

Usage

Before unpacking the tar ball, clear attributes via xattr -c swift-PR-78531-*.tar

Use DYLD_LIBRARY_PATH and the bundled swift executable via

DYLD_LIBRARY_PATH=~/Downloads/Library/Developer/Toolchains/swift-PR-78531-xxxx.xctoolchain/usr/lib/swift/macosx  ~/Downloads/Library/Developer/Toolchains/swift-PR-78531-xxxx.xctoolchain/usr/bin/swift run

Known issues

  • The String.utf8Span property is unavailable, pending [SE-0456] Span properties over utf8 views #80116.
  • Canonical comparisons can be slow, pending some more internal refactoring
  • checkForNFC(quickCheck: true) is unavailable, pending some more internal refactoring
  • canonicallyPrecedes is still called isCanonicallyLessThan

@milseman
Copy link
Member Author

@swift-ci Please Build Toolchain macOS Platform

@milseman
Copy link
Member Author

@swift-ci Please Build Toolchain macOS Platform

@milseman
Copy link
Member Author

milseman commented Mar 2, 2025

@swift-ci Please Build Toolchain macOS Platform

@milseman
Copy link
Member Author

milseman commented Mar 3, 2025

@milseman
Copy link
Member Author

milseman commented Mar 3, 2025

@swift-ci Please Build Toolchain macOS Platform

1 similar comment
@milseman
Copy link
Member Author

milseman commented Mar 3, 2025

@swift-ci Please Build Toolchain macOS Platform

@milseman
Copy link
Member Author

milseman commented Mar 6, 2025

@milseman
Copy link
Member Author

milseman commented Mar 8, 2025

@swift-ci Please Build Toolchain macOS Platform

@milseman
Copy link
Member Author

milseman commented Mar 9, 2025

@milseman
Copy link
Member Author

@swift-ci Please Build Toolchain macOS Platform

@milseman
Copy link
Member Author

@milseman
Copy link
Member Author

@swift-ci Please Build Toolchain macOS Platform

@milseman
Copy link
Member Author

@swift-ci Please Build Toolchain macOS Platform

@milseman
Copy link
Member Author

@swift-ci please test

1 similar comment
@milseman
Copy link
Member Author

@swift-ci please test

@milseman
Copy link
Member Author

milseman commented Apr 4, 2025

@swift-ci Please Build Toolchain macOS Platform

@milseman
Copy link
Member Author

milseman commented Apr 4, 2025

@swift-ci please test

4 similar comments
@milseman
Copy link
Member Author

milseman commented Apr 6, 2025

@swift-ci please test

@milseman
Copy link
Member Author

milseman commented Apr 6, 2025

@swift-ci please test

@milseman
Copy link
Member Author

milseman commented Apr 6, 2025

@swift-ci please test

@milseman
Copy link
Member Author

milseman commented Apr 6, 2025

@swift-ci please test

Internal refactoring. Validation now produces a (discardable) reason validation failed (only checked on slow-path). _hasGraphemeBreakBetween has been refactored to represent its quick-check nature.
@milseman
Copy link
Member Author

milseman commented Apr 7, 2025

@swift-ci please test

1 similar comment
@milseman
Copy link
Member Author

milseman commented Apr 7, 2025

@swift-ci please test

wip: closer to proposal

wip

wip: more implementation

wip: add back in comparison functions

wip: more iterator testing

Detangle grapheme breaking guts from string guts

Further untangling

wip

wip: use internal grapheme breaking

Call internal impl directly

wip refactoring

wip: might be broken

wip: update to lifetime changes

wip: wire up nfc quick check

wip: validation error rename

SQUASH ME: unsafe annotations, final API

wip: fixup availability

wip: re-arrange availability

wip: x86 abi additions

wip: fix availability

wip: Windows build support

wip: refine assertions
@milseman
Copy link
Member Author

milseman commented Apr 9, 2025

(As a note for the future, since bot history got removed, full CI testing passed.)

@milseman
Copy link
Member Author

milseman commented Apr 9, 2025

@swift-ci please test

@milseman
Copy link
Member Author

@swift-ci please test

@milseman
Copy link
Member Author

Passing CI build: https://ci.swift.org/job/swift-PR-macos/21480/

@milseman milseman marked this pull request as ready for review April 10, 2025 17:04
@milseman milseman requested a review from glessard April 10, 2025 17:04
Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

The build changes seem fine to me.

UTF8SpanFundamentals.swift
UTF8SpanInternalHelpers.swift
UTF8SpanIterators.swift
UTF8EncodingError.swift
Copy link
Member

Choose a reason for hiding this comment

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

Is this sorted properly? Should they be ordered around UTF8.swift?

Copy link
Member Author

Choose a reason for hiding this comment

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

I went through and put them in alphabetical order, thanks.

@inline(__always) func guaranteeIn(_ f: (UInt8) -> Bool) throws(UTF8ValidationError) {
guard let cu = unsafe iter.next() else { throw UTF8ValidationError() }
guard f(cu) else { throw UTF8ValidationError() }
@inline(__always) func guarantee(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@inline(__always) func guarantee(
@inline(__always)
internal func guarantee(

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a nested function, so we can't attach internal to it.

}
@inline(__always) func guaranteeContinuation() throws(UTF8ValidationError) {
try guaranteeIn(UTF8.isContinuation)
@inline(__always) func guaranteeContinuation(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@inline(__always) func guaranteeContinuation(
@inline(__always)
internal func guaranteeContinuation(

@milseman milseman changed the title DRAFT: UTF8Span UTF8Span Apr 11, 2025
@milseman
Copy link
Member Author

@swift-ci please test

@milseman
Copy link
Member Author

@swift-ci please test linux platform

@milseman
Copy link
Member Author

@swift-ci please test windows platform

@milseman
Copy link
Member Author

@swift-ci please test linux platform

@milseman
Copy link
Member Author

@swift-ci please test

@milseman milseman merged commit e6e4bd6 into swiftlang:main Apr 11, 2025
5 checks passed
@milseman milseman deleted the utf8span branch April 11, 2025 22:11
milseman added a commit to milseman/swift that referenced this pull request Apr 17, 2025
Add support for UTF8Span

Also, refactor validation and grapheme breaking
stephentyrone pushed a commit that referenced this pull request Apr 18, 2025
Add support for UTF8Span

Also, refactor validation and grapheme breaking
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.

3 participants