Skip to content

Foundation: update index -> firstIndex (NFCI) #1881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Foundation/HTTPCookie.swift
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ open class HTTPCookie : NSObject {
//Cookie attribute names are case-insensitive as per RFC6265: https://tools.ietf.org/html/rfc6265
//but HTTPCookie needs only the first letter of each attribute in uppercase
private class func canonicalize(_ name: String) -> HTTPCookiePropertyKey {
let idx = _attributes.index(where: {$0.rawValue.caseInsensitiveCompare(name) == .orderedSame})!
let idx = _attributes.firstIndex(where: {$0.rawValue.caseInsensitiveCompare(name) == .orderedSame})!
return _attributes[idx]
}

Expand Down
2 changes: 1 addition & 1 deletion Foundation/JSONEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ open class JSONDecoder {
guard !stringKey.isEmpty else { return stringKey }

// Find the first non-underscore character
guard let firstNonUnderscore = stringKey.index(where: { $0 != "_" }) else {
guard let firstNonUnderscore = stringKey.firstIndex(where: { $0 != "_" }) else {
// Reached the end without finding an _
return stringKey
}
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSCFSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ internal func _CFSwiftSetGetValues(_ set: AnyObject, _ values: UnsafeMutablePoin
internal func _CFSwiftSetGetValue(_ set: AnyObject, value: AnyObject, key: AnyObject) -> Unmanaged<AnyObject>? {
let set = set as! NSSet
if type(of: set) === NSSet.self || type(of: set) === NSMutableSet.self {
if let idx = set._storage.index(of: value as! NSObject){
if let idx = set._storage.firstIndex(of: value as! NSObject){
return Unmanaged<AnyObject>.passUnretained(set._storage[idx])
}

Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSOrderedSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ open class NSOrderedSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding,
}

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

public convenience override init() {
Expand Down