Skip to content

Commit bcc12c8

Browse files
authored
Merge pull request #1881 from compnerd/first
Foundation: update `index` -> `firstIndex` (NFCI)
2 parents 3198676 + 125825b commit bcc12c8

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

Foundation/HTTPCookie.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ open class HTTPCookie : NSObject {
481481
//Cookie attribute names are case-insensitive as per RFC6265: https://tools.ietf.org/html/rfc6265
482482
//but HTTPCookie needs only the first letter of each attribute in uppercase
483483
private class func canonicalize(_ name: String) -> HTTPCookiePropertyKey {
484-
let idx = _attributes.index(where: {$0.rawValue.caseInsensitiveCompare(name) == .orderedSame})!
484+
let idx = _attributes.firstIndex(where: {$0.rawValue.caseInsensitiveCompare(name) == .orderedSame})!
485485
return _attributes[idx]
486486
}
487487

Foundation/JSONEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ open class JSONDecoder {
10151015
guard !stringKey.isEmpty else { return stringKey }
10161016

10171017
// Find the first non-underscore character
1018-
guard let firstNonUnderscore = stringKey.index(where: { $0 != "_" }) else {
1018+
guard let firstNonUnderscore = stringKey.firstIndex(where: { $0 != "_" }) else {
10191019
// Reached the end without finding an _
10201020
return stringKey
10211021
}

Foundation/NSCFSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ internal func _CFSwiftSetGetValues(_ set: AnyObject, _ values: UnsafeMutablePoin
117117
internal func _CFSwiftSetGetValue(_ set: AnyObject, value: AnyObject, key: AnyObject) -> Unmanaged<AnyObject>? {
118118
let set = set as! NSSet
119119
if type(of: set) === NSSet.self || type(of: set) === NSMutableSet.self {
120-
if let idx = set._storage.index(of: value as! NSObject){
120+
if let idx = set._storage.firstIndex(of: value as! NSObject){
121121
return Unmanaged<AnyObject>.passUnretained(set._storage[idx])
122122
}
123123

Foundation/NSOrderedSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ open class NSOrderedSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding,
7272
}
7373

7474
open func index(of object: Any) -> Int {
75-
return _orderedStorage.index(of: __SwiftValue.store(object)) ?? NSNotFound
75+
return _orderedStorage.firstIndex(of: __SwiftValue.store(object)) ?? NSNotFound
7676
}
7777

7878
public convenience override init() {

0 commit comments

Comments
 (0)