Skip to content

Commit b0f30c8

Browse files
authored
Merge pull request #26125 from lorentey/cutting-the-gordian-array-count
[stdlib] Simplify __SwiftNativeNSArrayWithContiguousStorage.count
2 parents c829703 + d186e9c commit b0f30c8

File tree

2 files changed

+1
-29
lines changed

2 files changed

+1
-29
lines changed

stdlib/public/core/ContiguousArrayBuffer.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ internal final class __EmptyArrayStorage
4040
return try body(UnsafeBufferPointer(start: nil, count: 0))
4141
}
4242

43-
@nonobjc
44-
override internal func _getNonVerbatimBridgedCount() -> Int {
45-
return 0
46-
}
47-
4843
override internal func _getNonVerbatimBridgingBuffer() -> _BridgingBuffer {
4944
return _BridgingBuffer(0)
5045
}
@@ -111,17 +106,6 @@ internal final class _ContiguousArrayStorage<
111106
}
112107
}
113108

114-
/// Returns the number of elements in the array.
115-
///
116-
/// - Precondition: `Element` is bridged non-verbatim.
117-
@nonobjc
118-
override internal func _getNonVerbatimBridgedCount() -> Int {
119-
_internalInvariant(
120-
!_isBridgedVerbatimToObjectiveC(Element.self),
121-
"Verbatim bridging should be handled separately")
122-
return countAndCapacity.count
123-
}
124-
125109
/// Bridge array elements and return a new buffer that owns them.
126110
///
127111
/// - Precondition: `Element` is bridged non-verbatim.

stdlib/public/core/SwiftNativeNSArray.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,7 @@ extension __SwiftNativeNSArrayWithContiguousStorage : _NSArrayCore {
232232
/// bridging of array elements.
233233
@objc
234234
internal override var count: Int {
235-
if let bridgedStorage = _heapBufferBridged {
236-
return _BridgingBuffer(bridgedStorage).count
237-
}
238-
239-
// Check if elements are bridged verbatim.
240-
return _nativeStorage._withVerbatimBridgedUnsafeBuffer { $0.count }
241-
?? _nativeStorage._getNonVerbatimBridgedCount()
235+
return _nativeStorage.countAndCapacity.count
242236
}
243237
}
244238
#else
@@ -294,12 +288,6 @@ internal class __ContiguousArrayStorageBase
294288
"Concrete subclasses must implement _withVerbatimBridgedUnsafeBuffer")
295289
}
296290

297-
@nonobjc
298-
internal func _getNonVerbatimBridgedCount() -> Int {
299-
_internalInvariantFailure(
300-
"Concrete subclasses must implement _getNonVerbatimBridgedCount")
301-
}
302-
303291
internal func _getNonVerbatimBridgingBuffer() -> _BridgingBuffer {
304292
_internalInvariantFailure(
305293
"Concrete subclasses must implement _getNonVerbatimBridgingBuffer")

0 commit comments

Comments
 (0)