Skip to content

Commit 18dad29

Browse files
authored
Merge pull request #1832 from compnerd/first
Foundation: update for API change
2 parents 12ee2c8 + be0544b commit 18dad29

File tree

8 files changed

+17
-16
lines changed

8 files changed

+17
-16
lines changed

Foundation/NSPathUtilities.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ extension NSString {
285285
return _swiftObject
286286
}
287287

288-
let endOfUserName = _swiftObject.index(of: "/") ?? _swiftObject.endIndex
288+
let endOfUserName = _swiftObject.firstIndex(of: "/") ?? _swiftObject.endIndex
289289
let startOfUserName = _swiftObject.index(after: _swiftObject.startIndex)
290290
let userName = String(_swiftObject[startOfUserName..<endOfUserName])
291291
let optUserName: String? = userName.isEmpty ? nil : userName

Foundation/NSSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ open class NSSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCodi
2626
NSRequiresConcreteImplementation()
2727
}
2828
let value = __SwiftValue.store(object)
29-
guard let idx = _storage.index(of: value) else { return nil }
29+
guard let idx = _storage.firstIndex(of: value) else { return nil }
3030
return _storage[idx]
3131
}
3232

Foundation/Operation.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ open class Operation : NSObject {
130130
_dependencies.remove(op)
131131
op.lock.lock()
132132
#if DEPLOYMENT_ENABLE_LIBDISPATCH
133-
let groupIndex = op._groups.index(where: { $0 === self._depGroup })
133+
let groupIndex = op._groups.firstIndex(where: { $0 === self._depGroup })
134134
if let idx = groupIndex {
135135
let group = op._groups.remove(at: idx)
136136
group.leave()
@@ -259,28 +259,28 @@ internal struct _OperationList {
259259
}
260260

261261
mutating func remove(_ operation: Operation) {
262-
if let idx = all.index(of: operation) {
262+
if let idx = all.firstIndex(of: operation) {
263263
all.remove(at: idx)
264264
}
265265
switch operation.queuePriority {
266266
case .veryLow:
267-
if let idx = veryLow.index(of: operation) {
267+
if let idx = veryLow.firstIndex(of: operation) {
268268
veryLow.remove(at: idx)
269269
}
270270
case .low:
271-
if let idx = low.index(of: operation) {
271+
if let idx = low.firstIndex(of: operation) {
272272
low.remove(at: idx)
273273
}
274274
case .normal:
275-
if let idx = normal.index(of: operation) {
275+
if let idx = normal.firstIndex(of: operation) {
276276
normal.remove(at: idx)
277277
}
278278
case .high:
279-
if let idx = high.index(of: operation) {
279+
if let idx = high.firstIndex(of: operation) {
280280
high.remove(at: idx)
281281
}
282282
case .veryHigh:
283-
if let idx = veryHigh.index(of: operation) {
283+
if let idx = veryHigh.firstIndex(of: operation) {
284284
veryHigh.remove(at: idx)
285285
}
286286
}

Foundation/ProcessInfo.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ open class ProcessInfo: NSObject {
4949
var idx = 0
5050

5151
while let entry = envp.advanced(by: idx).pointee {
52-
if let entry = String(cString: entry, encoding: strEncoding), let i = entry.index(of: equalSign) {
52+
if let entry = String(cString: entry, encoding: strEncoding),
53+
let i = entry.firstIndex(of: equalSign) {
5354
let key = String(entry.prefix(upTo: i))
5455
let value = String(entry.suffix(from: i).dropFirst())
5556
env[key] = value

Foundation/URLProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ open class URLProtocol : NSObject {
399399
*/
400400
open class func unregisterClass(_ protocolClass: AnyClass) {
401401
_classesLock.lock()
402-
if let idx = _registeredProtocolClasses.index(where: { $0 === protocolClass }) {
402+
if let idx = _registeredProtocolClasses.firstIndex(where: { $0 === protocolClass }) {
403403
_registeredProtocolClasses.remove(at: idx)
404404
}
405405
_classesLock.unlock()

Foundation/URLSession/http/HTTPMessage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private extension _HTTPURLProtocol._HTTPMessage._StartLine {
117117
} else if let version = _HTTPURLProtocol._HTTPMessage._Version(versionString: r.2),
118118
let URI = URL(string: r.1) {
119119
// The request method must be a token (i.e. without seperators):
120-
let seperatorIdx = r.0.unicodeScalars.index(where: { !$0.isValidMessageToken } )
120+
let seperatorIdx = r.0.unicodeScalars.firstIndex(where: { !$0.isValidMessageToken } )
121121
guard seperatorIdx == nil else { return nil }
122122
self = .requestLine(method: r.0, uri: URI, version: version)
123123
} else {
@@ -241,7 +241,7 @@ private extension String.UnicodeScalarView.SubSequence {
241241
/// The range of space (U+0020) characters.
242242
var rangeOfSpace: Range<Index>? {
243243
guard !isEmpty else { return startIndex..<startIndex }
244-
guard let idx = index(of: _Delimiters.Space!) else { return nil }
244+
guard let idx = firstIndex(of: _Delimiters.Space!) else { return nil }
245245
return idx..<self.index(after: idx)
246246
}
247247
// Has a space (SP) or horizontal tab (HT) prefix

Foundation/URLSession/libcurl/MultiHandle.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ internal extension URLSession._MultiHandle {
152152
}
153153
/// Remove an easy handle -- stop its transfer.
154154
func remove(_ handle: _EasyHandle) {
155-
guard let idx = self.easyHandles.index(of: handle) else {
155+
guard let idx = self.easyHandles.firstIndex(of: handle) else {
156156
fatalError("Handle not in list.")
157157
}
158158
self.easyHandles.remove(at: idx)
@@ -197,7 +197,7 @@ fileprivate extension URLSession._MultiHandle {
197197
/// Transfer completed.
198198
func completedTransfer(forEasyHandle handle: CFURLSessionEasyHandle, easyCode: CFURLSessionEasyCode) {
199199
// Look up the matching wrapper:
200-
guard let idx = easyHandles.index(where: { $0.rawHandle == handle }) else {
200+
guard let idx = easyHandles.firstIndex(where: { $0.rawHandle == handle }) else {
201201
fatalError("Tansfer completed for easy handle, but it is not in the list of added handles.")
202202
}
203203
let easyHandle = easyHandles[idx]

Foundation/XMLNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ open class XMLNode: NSObject, NSCopying {
467467
*/
468468
open var index: Int {
469469
if let siblings = self.parent?.children,
470-
let index = siblings.index(of: self) {
470+
let index = siblings.firstIndex(of: self) {
471471
return index
472472
}
473473

0 commit comments

Comments
 (0)