Skip to content

Commit 5858671

Browse files
committed
Expunge _preprocessingPass
1 parent 8ed2769 commit 5858671

File tree

10 files changed

+22
-185
lines changed

10 files changed

+22
-185
lines changed

stdlib/private/StdlibCollectionUnittest/CheckSequenceInstance.swift

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -87,32 +87,6 @@ public func checkSequence<
8787
expectGE(
8888
expectedCount, sequence.underestimatedCount, message(),
8989
stackTrace: stackTrace.pushIf(showFrame, file: file, line: line))
90-
91-
// Test `_copyContents(initializing:)` if we can do so without destroying the
92-
// sequence.
93-
_ = sequence._preprocessingPass { () -> Void in
94-
var count = 0
95-
for _ in sequence { count += 1 }
96-
let ptr = UnsafeMutablePointer<S.Element>.allocate(capacity: count)
97-
let buf = UnsafeMutableBufferPointer(start: ptr, count: count)
98-
var (remainders,writtenUpTo) = sequence._copyContents(initializing: buf)
99-
expectTrue(remainders.next() == nil,
100-
"_copyContents returned unwritten elements")
101-
expectTrue(writtenUpTo == buf.endIndex,
102-
"_copyContents failed to use entire buffer")
103-
expectEqualSequence(expected, buf, message(),
104-
stackTrace: stackTrace.pushIf(showFrame, file: file, line: line), sameValue: sameValue)
105-
ptr.deinitialize(count: count)
106-
ptr.deallocate()
107-
}
108-
109-
// Test `_copyToContiguousArray()` if we can do so
110-
// without destroying the sequence.
111-
_ = sequence._preprocessingPass { () -> Void in
112-
let copy = sequence._copyToContiguousArray()
113-
expectEqualSequence(expected, copy, message(),
114-
stackTrace: stackTrace.pushIf(showFrame, file: file, line: line), sameValue: sameValue)
115-
}
11690
}
11791

11892
public func checkSequence<
@@ -206,32 +180,6 @@ public func checkSequence<
206180
expectGE(
207181
expectedCount, sequence.underestimatedCount, message(),
208182
stackTrace: stackTrace.pushIf(showFrame, file: file, line: line))
209-
210-
// Test `_copyContents(initializing:)` if we can do so without destroying the
211-
// sequence.
212-
_ = sequence._preprocessingPass { () -> Void in
213-
var count = 0
214-
for _ in sequence { count += 1 }
215-
let ptr = UnsafeMutablePointer<S.Element>.allocate(capacity: count)
216-
let buf = UnsafeMutableBufferPointer(start: ptr, count: count)
217-
var (remainders,writtenUpTo) = sequence._copyContents(initializing: buf)
218-
expectTrue(remainders.next() == nil,
219-
"_copyContents returned unwritten elements")
220-
expectTrue(writtenUpTo == buf.endIndex,
221-
"_copyContents failed to use entire buffer")
222-
expectEqualSequence(expected, buf, message(),
223-
stackTrace: stackTrace.pushIf(showFrame, file: file, line: line), sameValue: sameValue)
224-
ptr.deinitialize(count: count)
225-
ptr.deallocate()
226-
}
227-
228-
// Test `_copyToContiguousArray()` if we can do so
229-
// without destroying the sequence.
230-
_ = sequence._preprocessingPass { () -> Void in
231-
let copy = sequence._copyToContiguousArray()
232-
expectEqualSequence(expected, copy, message(),
233-
stackTrace: stackTrace.pushIf(showFrame, file: file, line: line), sameValue: sameValue)
234-
}
235183
}
236184

237185
public func checkSequence<

stdlib/private/StdlibCollectionUnittest/CheckSequenceType.swift

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,52 +1978,6 @@ self.test("\(testNamePrefix).first(where:)/semantics") {
19781978
}
19791979
}
19801980

1981-
//===----------------------------------------------------------------------===//
1982-
// _preprocessingPass()
1983-
//===----------------------------------------------------------------------===//
1984-
1985-
self.test("\(testNamePrefix)._preprocessingPass/semantics") {
1986-
for test in forEachTests {
1987-
let s = makeWrappedSequence(test.sequence.map(OpaqueValue.init))
1988-
var wasInvoked = false
1989-
let result = s._preprocessingPass {
1990-
() -> OpaqueValue<Int> in
1991-
wasInvoked = true
1992-
1993-
expectEqualSequence(
1994-
test.sequence,
1995-
s.map { extractValue($0).value })
1996-
1997-
return OpaqueValue(42)
1998-
}
1999-
if wasInvoked {
2000-
expectEqual(42, result?.value)
2001-
} else {
2002-
expectNil(result)
2003-
}
2004-
}
2005-
2006-
for test in forEachTests {
2007-
let s = makeWrappedSequence(test.sequence.map(OpaqueValue.init))
2008-
var wasInvoked = false
2009-
var caughtError: Error?
2010-
var result: OpaqueValue<Int>?
2011-
do {
2012-
result = try s._preprocessingPass {
2013-
() -> OpaqueValue<Int> in
2014-
wasInvoked = true
2015-
throw TestError.error2
2016-
}
2017-
} catch {
2018-
caughtError = error
2019-
}
2020-
expectNil(result)
2021-
if wasInvoked {
2022-
expectEqual(TestError.error2, caughtError as? TestError)
2023-
}
2024-
}
2025-
}
2026-
20271981
//===----------------------------------------------------------------------===//
20281982
} // addSequenceTests
20291983
}

stdlib/private/StdlibCollectionUnittest/LoggingWrappers.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public class SequenceLog {
8484
public static var prefixMaxLength = TypeIndexed(0)
8585
public static var suffixMaxLength = TypeIndexed(0)
8686
public static var _customContainsEquatableElement = TypeIndexed(0)
87-
public static var _preprocessingPass = TypeIndexed(0)
8887
public static var _copyToContiguousArray = TypeIndexed(0)
8988
public static var _copyContents = TypeIndexed(0)
9089
// Collection
@@ -217,16 +216,6 @@ extension LoggingSequence: Sequence {
217216
return base._customContainsEquatableElement(element)
218217
}
219218

220-
/// If `self` is multi-pass (i.e., a `Collection`), invoke
221-
/// `preprocess` on `self` and return its result. Otherwise, return
222-
/// `nil`.
223-
public func _preprocessingPass<R>(
224-
_ preprocess: () throws -> R
225-
) rethrows -> R? {
226-
SequenceLog._preprocessingPass[selfType] += 1
227-
return try base._preprocessingPass(preprocess)
228-
}
229-
230219
/// Create a native array buffer containing the elements of `self`,
231220
/// in the same order.
232221
public func _copyToContiguousArray() -> ContiguousArray<Element> {

stdlib/public/core/Collection.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,13 +1668,3 @@ extension Collection where SubSequence == Self {
16681668
self = self[index(startIndex, offsetBy: k)..<endIndex]
16691669
}
16701670
}
1671-
1672-
extension Collection {
1673-
@inlinable
1674-
@inline(__always)
1675-
public func _preprocessingPass<R>(
1676-
_ preprocess: () throws -> R
1677-
) rethrows -> R? {
1678-
return try preprocess()
1679-
}
1680-
}

stdlib/public/core/ExistentialCollection.swift.gyb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,6 @@ internal class _AnyRandomAccessCollectionBox<Element>
220220
_abstract()
221221
}
222222

223-
@inlinable
224-
internal func __preprocessingPass<R>(
225-
_ preprocess: () throws -> R
226-
) rethrows -> R? {
227-
_abstract()
228-
}
229-
230223
@inlinable
231224
internal func __copyToContiguousArray() -> ContiguousArray<Element> {
232225
_abstract()
@@ -471,12 +464,6 @@ internal final class _${Kind}Box<S : ${Kind}> : _Any${Kind}Box<S.Element>
471464
return _base._customContainsEquatableElement(element)
472465
}
473466
@inlinable
474-
internal override func __preprocessingPass<R>(
475-
_ preprocess: () throws -> R
476-
) rethrows -> R? {
477-
return try _base._preprocessingPass(preprocess)
478-
}
479-
@inlinable
480467
internal override func __copyToContiguousArray() -> ContiguousArray<Element> {
481468
return _base._copyToContiguousArray()
482469
}
@@ -830,13 +817,6 @@ extension Any${Kind} {
830817
return _box.__customContainsEquatableElement(element)
831818
}
832819

833-
@inlinable
834-
public func _preprocessingPass<R>(
835-
_ preprocess: () throws -> R
836-
) rethrows -> R? {
837-
return try _box.__preprocessingPass(preprocess)
838-
}
839-
840820
@inlinable
841821
public __consuming func _copyToContiguousArray() -> ContiguousArray<Element> {
842822
return self._box.__copyToContiguousArray()

stdlib/public/core/Join.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,7 @@ extension JoinedSequence: Sequence {
133133
@inlinable // lazy-performance
134134
public __consuming func _copyToContiguousArray() -> ContiguousArray<Element> {
135135
var result = ContiguousArray<Element>()
136-
let separatorSize: Int = numericCast(_separator.count)
137-
138-
let reservation = _base._preprocessingPass {
139-
() -> Int in
140-
var r = 0
141-
for chunk in _base {
142-
r += separatorSize + chunk.underestimatedCount
143-
}
144-
return r - separatorSize
145-
}
146-
147-
if let n = reservation {
148-
result.reserveCapacity(numericCast(n))
149-
}
136+
let separatorSize = _separator.count
150137

151138
if separatorSize == 0 {
152139
for x in _base {

stdlib/public/core/Sequence.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,6 @@ public protocol Sequence {
353353
_ element: Element
354354
) -> Bool?
355355

356-
/// If `self` is multi-pass (i.e., a `Collection`), invoke `preprocess` and
357-
/// return its result. Otherwise, return `nil`.
358-
func _preprocessingPass<R>(
359-
_ preprocess: () throws -> R
360-
) rethrows -> R?
361-
362356
/// Create a native array buffer containing the elements of `self`,
363357
/// in the same order.
364358
__consuming func _copyToContiguousArray() -> ContiguousArray<Element>
@@ -665,14 +659,6 @@ extension Sequence {
665659
return 0
666660
}
667661

668-
@inlinable
669-
@inline(__always)
670-
public func _preprocessingPass<R>(
671-
_ preprocess: () throws -> R
672-
) rethrows -> R? {
673-
return nil
674-
}
675-
676662
@inlinable
677663
@inline(__always)
678664
public func _customContainsEquatableElement(

stdlib/public/core/Stride.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,6 @@ extension StrideTo: Sequence {
289289
return count
290290
}
291291

292-
@inlinable
293-
public func _preprocessingPass<R>(
294-
_ preprocess: () throws -> R
295-
) rethrows -> R? {
296-
return try preprocess()
297-
}
298-
299292
@inlinable
300293
public func _customContainsEquatableElement(
301294
_ element: Element
@@ -504,13 +497,6 @@ extension StrideThrough: Sequence {
504497
return count
505498
}
506499

507-
@inlinable
508-
public func _preprocessingPass<R>(
509-
_ preprocess: () throws -> R
510-
) rethrows -> R? {
511-
return try preprocess()
512-
}
513-
514500
@inlinable
515501
public func _customContainsEquatableElement(
516502
_ element: Element

test/api-digester/Outputs/stability-stdlib-abi.swift.expected

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,24 @@ Var Dictionary.keys has declared type change from LazyMapCollection<Dictionary<
259259
Var Dictionary.values has declared type change from LazyMapCollection<Dictionary<τ_0_0, τ_0_1>, τ_0_1> to LazyMapSequence<Dictionary<τ_0_0, τ_0_1>, τ_0_1>
260260
Var LazySequence._base has removed its setter
261261
Var _DropWhileSequence._iterator has declared type change from τ_0_0 to τ_0_0.Iterator
262+
Func Collection._preprocessingPass(_:) has been removed
263+
Func StrideThrough._preprocessingPass(_:) has been removed
264+
Func StrideTo._preprocessingPass(_:) has been removed
265+
Func AnyBidirectionalCollection._preprocessingPass(_:) has been removed
266+
Func AnyCollection._preprocessingPass(_:) has been removed
267+
Func AnyRandomAccessCollection._preprocessingPass(_:) has been removed
268+
Func AnySequence._preprocessingPass(_:) has been removed
269+
Func Sequence._preprocessingPass(_:) has been removed
270+
Func _AnySequenceBox.__copyContents(initializing:) in a non-resilient type changes position from 7 to 6
271+
Func _AnySequenceBox.__copyToContiguousArray() in a non-resilient type changes position from 6 to 5
272+
Func _AnySequenceBox.__preprocessingPass(_:) has been removed
273+
Func _AnySequenceBox._drop(while:) in a non-resilient type changes position from 8 to 7
274+
Func _AnySequenceBox._dropFirst(_:) in a non-resilient type changes position from 9 to 8
275+
Func _AnySequenceBox._dropLast(_:) in a non-resilient type changes position from 10 to 9
276+
Func _AnySequenceBox._prefix(_:) in a non-resilient type changes position from 11 to 10
277+
Func _AnySequenceBox._prefix(while:) in a non-resilient type changes position from 12 to 11
278+
Func _AnySequenceBox._suffix(_:) in a non-resilient type changes position from 13 to 12
279+
Func _BidirectionalCollectionBox.__preprocessingPass(_:) has been removed
280+
Func _CollectionBox.__preprocessingPass(_:) has been removed
281+
Func _RandomAccessCollectionBox.__preprocessingPass(_:) has been removed
282+
Func _SequenceBox.__preprocessingPass(_:) has been removed

validation-test/stdlib/ExistentialCollection.swift.gyb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ tests.test("${TestedType}: dispatch to wrapped, SequenceLog") {
155155
_ = s._customContainsEquatableElement(OpaqueValue(42))
156156
}
157157

158-
Log._preprocessingPass.expectIncrement(Base.self) {
159-
_ = s._preprocessingPass {}
160-
}
161-
162158
Log._copyToContiguousArray.expectIncrement(Base.self) {
163159
_ = s._copyToContiguousArray()
164160
}

0 commit comments

Comments
 (0)