Skip to content

Commit 87298c0

Browse files
committed
stdlib: make the non-native Array.count smaller more efficient.
Use _CocoaArrayWrapper.endIndex which returns the NSArray.count. In the old version, "count" translated to RandomAccessCollection.count, which ended up in multiple calls to endIndex.
1 parent d2e1f09 commit 87298c0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

stdlib/public/core/ArrayBuffer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ extension _ArrayBuffer {
266266
internal var count: Int {
267267
@inline(__always)
268268
get {
269-
return _fastPath(_isNative) ? _native.count : _nonNative.count
269+
return _fastPath(_isNative) ? _native.count : _nonNative.endIndex
270270
}
271271
set {
272272
_internalInvariant(_isNative, "attempting to update count of Cocoa array")

0 commit comments

Comments
 (0)