Skip to content

Commit 428d269

Browse files
committed
[stdlib] Use Index typealias of InlineArray
1 parent 23e1741 commit 428d269

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

stdlib/public/core/InlineArray.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ extension InlineArray where Element: ~Copyable {
136136
/// - Complexity: O(*n*), where *n* is the number of elements in the array.
137137
@available(SwiftStdlib 6.2, *)
138138
@_alwaysEmitIntoClient
139-
public init<E: Error>(_ body: (Int) throws(E) -> Element) throws(E) {
139+
public init<E: Error>(_ body: (Index) throws(E) -> Element) throws(E) {
140140
#if $BuiltinEmplaceTypedThrows
141141
self = try Builtin.emplace { (rawPtr) throws(E) -> () in
142142
let buffer = InlineArray<count, Element>._initializationBuffer(
@@ -284,7 +284,7 @@ extension InlineArray where Element: ~Copyable {
284284
@available(SwiftStdlib 6.2, *)
285285
@_alwaysEmitIntoClient
286286
@_transparent
287-
public var startIndex: Int {
287+
public var startIndex: Index {
288288
0
289289
}
290290

@@ -297,7 +297,7 @@ extension InlineArray where Element: ~Copyable {
297297
@available(SwiftStdlib 6.2, *)
298298
@_alwaysEmitIntoClient
299299
@_transparent
300-
public var endIndex: Int {
300+
public var endIndex: Index {
301301
count
302302
}
303303

@@ -307,7 +307,7 @@ extension InlineArray where Element: ~Copyable {
307307
@available(SwiftStdlib 6.2, *)
308308
@_alwaysEmitIntoClient
309309
@_transparent
310-
public var indices: Range<Int> {
310+
public var indices: Range<Index> {
311311
Range(_uncheckedBounds: (0, count))
312312
}
313313

@@ -321,7 +321,7 @@ extension InlineArray where Element: ~Copyable {
321321
@available(SwiftStdlib 6.2, *)
322322
@_alwaysEmitIntoClient
323323
@_transparent
324-
public borrowing func index(after i: Int) -> Int {
324+
public borrowing func index(after i: Index) -> Index {
325325
i &+ 1
326326
}
327327

@@ -335,14 +335,14 @@ extension InlineArray where Element: ~Copyable {
335335
@available(SwiftStdlib 6.2, *)
336336
@_alwaysEmitIntoClient
337337
@_transparent
338-
public borrowing func index(before i: Int) -> Int {
338+
public borrowing func index(before i: Index) -> Index {
339339
i &- 1
340340
}
341341

342342
@_alwaysEmitIntoClient
343343
@_semantics("fixed_storage.check_index")
344344
@inline(__always)
345-
internal func _checkIndex(_ i: Int) {
345+
internal func _checkIndex(_ i: Index) {
346346
_precondition(indices.contains(i), "Index out of bounds")
347347
}
348348

@@ -355,7 +355,7 @@ extension InlineArray where Element: ~Copyable {
355355
@available(SwiftStdlib 6.2, *)
356356
@_addressableSelf
357357
@_alwaysEmitIntoClient
358-
public subscript(_ i: Int) -> Element {
358+
public subscript(_ i: Index) -> Element {
359359
@_transparent
360360
unsafeAddress {
361361
_checkIndex(i)
@@ -389,8 +389,8 @@ extension InlineArray where Element: ~Copyable {
389389
@available(SwiftStdlib 6.2, *)
390390
@_alwaysEmitIntoClient
391391
public mutating func swapAt(
392-
_ i: Int,
393-
_ j: Int
392+
_ i: Index,
393+
_ j: Index
394394
) {
395395
guard i != j else {
396396
return

0 commit comments

Comments
 (0)