Skip to content

Commit 4194c16

Browse files
authored
Merge pull request swiftlang#29128 from apple/revert-29094-cb-substring-fast-access
Revert "[stdlib] Add withContiguousStorageIfAvailable to SubString.UTF8View"
2 parents bbcff82 + 70e6db8 commit 4194c16

File tree

2 files changed

+0
-27
lines changed

2 files changed

+0
-27
lines changed

stdlib/public/core/Substring.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,6 @@ extension Substring.UTF8View: BidirectionalCollection {
389389
return _slice.distance(from: start, to: end)
390390
}
391391

392-
@_alwaysEmitIntoClient
393-
public func withContiguousStorageIfAvailable<R>(
394-
_ body: (UnsafeBufferPointer<Element>) throws -> R
395-
) rethrows -> R? {
396-
return try _slice.withContiguousStorageIfAvailable(body)
397-
}
398-
399392
@inlinable
400393
public func _failEarlyRangeCheck(_ index: Index, bounds: Range<Index>) {
401394
_slice._failEarlyRangeCheck(index, bounds: bounds)

test/stdlib/subString.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@ func checkMatch<S: Collection, T: Collection>(_ x: S, _ y: T, _ i: S.Index)
1212
expectEqual(x[i], y[i])
1313
}
1414

15-
func checkMatchContiguousStorage<S: Collection, T: Collection>(_ x: S, _ y: T)
16-
where S.Element == T.Element, S.Element: Equatable
17-
{
18-
let xElement = x.withContiguousStorageIfAvailable { $0.first }
19-
let yElement = y.withContiguousStorageIfAvailable { $0.first }
20-
expectEqual(xElement, yElement)
21-
}
22-
23-
func checkHasContiguousStorage<S: Collection>(_ x: S) {
24-
let hasStorage = x.withContiguousStorageIfAvailable { _ in true } ?? false
25-
expectTrue(hasStorage)
26-
}
27-
2815
SubstringTests.test("Equality") {
2916
let s = "abcdefg"
3017
let s1 = s[s.index(s.startIndex, offsetBy: 2) ..<
@@ -241,13 +228,6 @@ SubstringTests.test("UTF8View") {
241228
expectEqual("", String(t.dropLast(100))!)
242229
expectEqual("", String(u.dropFirst(100))!)
243230
expectEqual("", String(u.dropLast(100))!)
244-
245-
checkHasContiguousStorage(s.utf8)
246-
checkHasContiguousStorage(t)
247-
checkHasContiguousStorage(u)
248-
checkMatchContiguousStorage(Array(s.utf8), s.utf8)
249-
checkMatchContiguousStorage(Array(t), t)
250-
checkMatchContiguousStorage(Array(u), u)
251231
}
252232
}
253233

0 commit comments

Comments
 (0)