Skip to content

Commit 916eb2d

Browse files
airspeedswiftmoiseev
authored andcommitted
Revert count(where:)
(cherry picked from commit 779ea19)
1 parent 1e824b0 commit 916eb2d

File tree

7 files changed

+4
-188
lines changed

7 files changed

+4
-188
lines changed

benchmark/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ set(SWIFT_BENCH_MODULES
5656
single-source/Chars
5757
single-source/ClassArrayGetter
5858
single-source/Combos
59-
single-source/CountAlgo
6059
single-source/DataBenchmarks
6160
single-source/DeadArray
6261
single-source/DictOfArraysToArrayOfDicts

benchmark/single-source/CountAlgo.swift

Lines changed: 0 additions & 126 deletions
This file was deleted.

benchmark/utils/main.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import CharacterProperties
4444
import Chars
4545
import ClassArrayGetter
4646
import Combos
47-
import CountAlgo
4847
import DataBenchmarks
4948
import DeadArray
5049
import DictOfArraysToArrayOfDicts
@@ -213,7 +212,6 @@ registerBenchmark(CharacterPropertiesStashedMemo)
213212
registerBenchmark(CharacterPropertiesPrecomputed)
214213
registerBenchmark(Chars)
215214
registerBenchmark(Combos)
216-
registerBenchmark(CountAlgo)
217215
registerBenchmark(ClassArrayGetter)
218216
registerBenchmark(DataBenchmarks)
219217
registerBenchmark(DeadArray)

stdlib/public/core/SequenceAlgorithms.swift

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -572,50 +572,6 @@ extension Sequence where Element : Equatable {
572572
}
573573
}
574574

575-
//===----------------------------------------------------------------------===//
576-
// count(where:)
577-
//===----------------------------------------------------------------------===//
578-
579-
extension Sequence {
580-
/// Returns the number of elements in the sequence that satisfy the given
581-
/// predicate.
582-
///
583-
/// You can use this method to count the number of elements that pass a test.
584-
/// The following example finds the number of names that are fewer than
585-
/// five characters long:
586-
///
587-
/// let names = ["Jacqueline", "Ian", "Amy", "Juan", "Soroush", "Tiffany"]
588-
/// let shortNameCount = names.count(where: { $0.count < 5 })
589-
/// // shortNameCount == 3
590-
///
591-
/// To find the number of times a specific element appears in the sequence,
592-
/// use the equal to operator (`==`) in the closure to test for a match.
593-
///
594-
/// let birds = ["duck", "duck", "duck", "duck", "goose"]
595-
/// let duckCount = birds.count(where: { $0 == "duck" })
596-
/// // duckCount == 4
597-
///
598-
/// The sequence must be finite.
599-
///
600-
/// - Parameter predicate: A closure that takes each element of the sequence
601-
/// as its argument and returns a Boolean value indicating whether
602-
/// the element should be included in the count.
603-
/// - Returns: The number of elements in the sequence that satisfy the given
604-
/// predicate.
605-
@inlinable
606-
public func count(
607-
where predicate: (Element) throws -> Bool
608-
) rethrows -> Int {
609-
var count = 0
610-
for e in self {
611-
if try predicate(e) {
612-
count += 1
613-
}
614-
}
615-
return count
616-
}
617-
}
618-
619575
//===----------------------------------------------------------------------===//
620576
// reduce()
621577
//===----------------------------------------------------------------------===//

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,5 @@ Subscript String.UnicodeScalarView.subscript(_:) has been removed
148148
Subscript Substring.subscript(_:) has been removed
149149

150150
Func Collection.makeIterator() has self access kind changing from NonMutating to __Consuming
151+
152+
Func Sequence.count(where:) has been removed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ Protocol SIMD has added inherited protocol Decodable
44
Protocol SIMD has added inherited protocol Encodable
55
Protocol SIMD has generic signature change from <Self : CustomStringConvertible, Self : ExpressibleByArrayLiteral, Self : Hashable, Self : SIMDStorage, Self.MaskStorage : SIMD, Self.MaskStorage.Scalar : FixedWidthInteger, Self.MaskStorage.Scalar : SignedInteger> to <Self : CustomStringConvertible, Self : Decodable, Self : Encodable, Self : ExpressibleByArrayLiteral, Self : Hashable, Self : SIMDStorage, Self.MaskStorage : SIMD, Self.MaskStorage.Scalar : FixedWidthInteger, Self.MaskStorage.Scalar : SignedInteger>
66
Protocol SIMDStorage has generic signature change from <Self.Scalar : Hashable> to <Self.Scalar : Decodable, Self.Scalar : Encodable, Self.Scalar : Hashable>
7+
8+
Func Sequence.count(where:) has been removed

validation-test/stdlib/SequenceType.swift.gyb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -628,21 +628,6 @@ SequenceTypeTests.test("allSatisfy/Predicate") {
628628
}
629629
}
630630

631-
//===----------------------------------------------------------------------===//
632-
// count(where:)
633-
//===----------------------------------------------------------------------===//
634-
635-
SequenceTypeTests.test("count/Predicate") {
636-
for test in predicateCountTests {
637-
let s = MinimalSequence<OpaqueValue<Int>>(
638-
elements: test.sequence.map { OpaqueValue($0) })
639-
expectEqual(
640-
test.expected,
641-
s.count(where: { test.includeElement($0.value) }),
642-
stackTrace: SourceLocStack().with(test.loc))
643-
}
644-
}
645-
646631
//===----------------------------------------------------------------------===//
647632
// reduce()
648633
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)