Skip to content

Commit b8d90e0

Browse files
committed
Call internal impl directly
1 parent 9b43bfe commit b8d90e0

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

stdlib/public/core/StringComparison.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ internal func _stringCompareInternal(
9797
}
9898

9999
@_effects(readonly)
100-
private func _stringCompareFastUTF8(
100+
internal func _stringCompareFastUTF8(
101101
_ utf8Left: UnsafeBufferPointer<UInt8>,
102102
_ utf8Right: UnsafeBufferPointer<UInt8>,
103103
expecting: _StringComparisonResult,

stdlib/public/core/UTF8Span.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,22 @@ extension UTF8Span {
166166

167167
}
168168

169-
170-
func TODO(_ message: String) -> Never {
171-
fatalError("TODO: \(message)")
169+
func UNSUPPORTED(_ message: String) -> Never {
170+
fatalError("UNSUPPORTED: \(message)")
172171
}
173172

174173
// TODO(toolchain): decide if we rebase on top of Guillaume's work
175174
@available(SwiftStdlib 6.1, *)
176175
extension String {
177176
public var utf8Span: UTF8Span {
178-
TODO("Decide whether to rebase on top of Span PR or wait for merge")
177+
UNSUPPORTED("utf8Span property pending compiler fixes")
179178
}
180179
}
181180

182181
@available(SwiftStdlib 6.1, *)
183182
extension Substring {
184183
public var utf8Span: UTF8Span {
185-
TODO("Decide whether to rebase on top of Span PR or wait for merge")
184+
UNSUPPORTED("utf8Span property pending compiler fixes")
186185
}
187186
}
188187

stdlib/public/core/UTF8SpanBits.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extension UTF8Span {
7575
if s.value < 0x300 {
7676
continue
7777
}
78-
TODO("Refactor and adapt _StringGutsSlice._fastNFCCheck()")
78+
UNSUPPORTED("NFC quick check (pending internal refactoring)")
7979
}
8080
self._countAndFlags |= Self._nfcBit
8181
return true

stdlib/public/core/UTF8SpanComparisons.swift

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,31 @@ extension UTF8Span {
5757
public func isCanonicallyEquivalent(
5858
to other: UTF8Span
5959
) -> Bool {
60-
self._str == other._str
60+
self._withUnsafeBufferPointer { selfBufPtr in
61+
other._withUnsafeBufferPointer { otherBufPtr in
62+
_stringCompareFastUTF8(
63+
selfBufPtr,
64+
otherBufPtr,
65+
expecting: .equal,
66+
bothNFC: self.isKnownNFC && other.isKnownNFC)
67+
}
68+
}
6169
}
6270

63-
/// Whether `self` orders less than `other` under Unicode Canonical
71+
/// Whether `self` orders less than `other` under Unicode Canonical
6472
/// Equivalence using normalized code-unit order (in NFC).
6573
public func isCanonicallyLessThan(
6674
_ other: UTF8Span
6775
) -> Bool {
68-
self._str < other._str
76+
self._withUnsafeBufferPointer { selfBufPtr in
77+
other._withUnsafeBufferPointer { otherBufPtr in
78+
_stringCompareFastUTF8(
79+
selfBufPtr,
80+
otherBufPtr,
81+
expecting: .less,
82+
bothNFC: self.isKnownNFC && other.isKnownNFC)
83+
}
84+
}
6985
}
7086
}
7187

0 commit comments

Comments
 (0)