Skip to content

Commit 812894f

Browse files
committed
Adjust for SE-0065 "A New Model for Collections and Indices"
1 parent e64b1b9 commit 812894f

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

Sources/Build/PkgConfig.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ struct PkgConfigParser {
101101
guard let line = uncommentedLine.chuzzle() else { continue }
102102

103103
if let colonIndex = line.characters.index(of: ":") where
104-
line.endIndex == line.characters.location(after: colonIndex) || line[line.characters.location(after: colonIndex)] == " " {
104+
line.endIndex == line.characters.index(after: colonIndex) || line[line.characters.index(after: colonIndex)] == " " {
105105
// Found a key-value pair.
106106
try parseKeyValue(line: line)
107107
} else if let equalsIndex = line.characters.index(of: "=") {
108108
// Found a variable.
109109
let name = line[line.startIndex..<equalsIndex]
110-
let value = line[line.location(after: equalsIndex)..<line.endIndex]
110+
let value = line[line.index(after: equalsIndex)..<line.endIndex]
111111
variables[name] = try resolveVariables(value)
112112
} else {
113113
// unexpected thing in the pc file, abort.
@@ -136,7 +136,7 @@ struct PkgConfigParser {
136136
// Look at a char at an index if present.
137137
func peek(idx: Int) -> Character? {
138138
guard idx <= depString.characters.count - 1 else { return nil }
139-
return depString.characters[depString.characters.location(depString.characters.startIndex, offsetBy: idx)]
139+
return depString.characters[depString.characters.index(depString.characters.startIndex, offsetBy: idx)]
140140
}
141141

142142
// This converts the string which can be seperated by comma or spaces
@@ -189,9 +189,9 @@ struct PkgConfigParser {
189189
// We make sure it of form ${name} otherwise it is not a variable.
190190
func findVariable(_ fragment: String) -> (name: String, startIndex: StringIndex, endIndex: StringIndex)? {
191191
guard let dollar = fragment.characters.index(of: "$") else { return nil }
192-
guard dollar != fragment.endIndex && fragment.characters[fragment.location(after: dollar)] == "{" else { return nil }
192+
guard dollar != fragment.endIndex && fragment.characters[fragment.index(after: dollar)] == "{" else { return nil }
193193
guard let variableEndIndex = fragment.characters.index(of: "}") else { return nil }
194-
return (fragment[fragment.location(dollar, offsetBy: 2)..<variableEndIndex], dollar, variableEndIndex)
194+
return (fragment[fragment.index(dollar, offsetBy: 2)..<variableEndIndex], dollar, variableEndIndex)
195195
}
196196

197197
var result = ""
@@ -207,7 +207,7 @@ struct PkgConfigParser {
207207
// Append the value of the variable.
208208
result += variableValue
209209
// Update the fragment with post variable string.
210-
fragment = fragment[fragment.location(after: variable.endIndex)..<fragment.characters.endIndex]
210+
fragment = fragment[fragment.index(after: variable.endIndex)..<fragment.characters.endIndex]
211211
} else {
212212
// No variable found, just append rest of the fragment to result.
213213
result += fragment
@@ -221,6 +221,6 @@ struct PkgConfigParser {
221221
guard let colonIndex = line.characters.index(of: ":") else {
222222
return ""
223223
}
224-
return line[line.location(colonIndex, offsetBy: 2)..<line.endIndex]
224+
return line[line.index(colonIndex, offsetBy: 2)..<line.endIndex]
225225
}
226226
}

Sources/ManifestParser/TOML.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ private struct Lexer {
205205

206206
// Consume and cache the next character.
207207
lookahead = utf8[index]
208-
nextIndex = utf8.location(after: index)
208+
nextIndex = utf8.index(after: index)
209209

210210
// Normalize line endings.
211211
if lookahead == UInt8(ascii: "\r") && utf8[nextIndex!] == UInt8(ascii: "\n") {
212-
nextIndex = utf8.location(after: nextIndex!)
212+
nextIndex = utf8.index(after: nextIndex!)
213213
lookahead = UInt8(ascii: "\n")
214214
}
215215

@@ -269,7 +269,7 @@ private struct Lexer {
269269
break
270270
}
271271
}
272-
return .StringLiteral(value: String(utf8[utf8.location(after: startIndex)..<endIndex]))
272+
return .StringLiteral(value: String(utf8[utf8.index(after: startIndex)..<endIndex]))
273273

274274
// Numeric literals.
275275
//

Sources/OptionsParser/OptionsParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private func split(_ arg: String) -> (String, String?) {
8787
let chars = arg.characters
8888
if let ii = chars.index(of: "=") {
8989
let flag = chars.prefix(upTo: ii)
90-
let value = chars.suffix(from: chars.location(after: ii))
90+
let value = chars.suffix(from: chars.index(after: ii))
9191
return (String(flag), String(value))
9292
} else {
9393
return (arg, nil)

Sources/PackageDescription/Version+StringLiteralConvertible.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ extension Version {
4747

4848
if let prereleaseStartIndex = prereleaseStartIndex {
4949
let prereleaseEndIndex = metadataStartIndex ?? characters.endIndex
50-
let prereleaseCharacters = characters[characters.location(after: prereleaseStartIndex)..<prereleaseEndIndex]
50+
let prereleaseCharacters = characters[characters.index(after: prereleaseStartIndex)..<prereleaseEndIndex]
5151
prereleaseIdentifiers = prereleaseCharacters.split(separator: ".").map{ String($0) }
5252
} else {
5353
prereleaseIdentifiers = []
5454
}
5555

5656
var buildMetadataIdentifier: String? = nil
5757
if let metadataStartIndex = metadataStartIndex {
58-
let buildMetadataCharacters = characters.suffix(from: characters.location(after: metadataStartIndex))
58+
let buildMetadataCharacters = characters.suffix(from: characters.index(after: metadataStartIndex))
5959
if !buildMetadataCharacters.isEmpty {
6060
buildMetadataIdentifier = String(buildMetadataCharacters)
6161
}

Sources/PackageType/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extension Package {
5656
case "http", "https", "git", "ssh":
5757
if url.hasSuffix(".git") {
5858
let a = base.startIndex
59-
let b = base.location(base.endIndex, offsetBy: -4)
59+
let b = base.index(base.endIndex, offsetBy: -4)
6060
return base[a..<b]
6161
} else {
6262
fallthrough

Sources/Utility/Git.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public class Git {
8787
let prefix = "git version"
8888
var version = self.version
8989
if version.hasPrefix(prefix) {
90-
let prefixRange = version.startIndex...version.location(version.startIndex, offsetBy: prefix.characters.count)
90+
let prefixRange = version.startIndex...version.index(version.startIndex, offsetBy: prefix.characters.count)
9191
version.removeSubrange(prefixRange)
9292
}
9393
guard let first = version.characters.first else {

Sources/Utility/Path.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ extension String {
290290
let end = utf8.endIndex
291291
while idx != end {
292292
if utf8[idx] == UInt8(ascii: "/") {
293-
utf8.formLocation(after: &idx)
293+
utf8.formIndex(after: &idx)
294294
if idx == end || utf8[idx] == UInt8(ascii: "/") {
295295
return false
296296
}
297297
}
298-
utf8.formLocation(after: &idx)
298+
utf8.formIndex(after: &idx)
299299
}
300300
return true
301301
}

Sources/Utility/StringExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension String {
1818
func scrub(_ separator: String) -> String {
1919
var E = endIndex
2020
while self[startIndex..<E].hasSuffix(separator) && E > startIndex {
21-
E = location(before: E)
21+
E = index(before: E)
2222
}
2323
return self[startIndex..<E]
2424
}

Sources/libc/String+Linux.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
// FIXME: the complexity of this algorithm is O(n^2).
2121
for i in 0..<str.utf8.count {
22-
if utf8[utf8.location(utf8.startIndex, offsetBy: i)] != str.utf8[str.utf8.location(str.utf8.startIndex, offsetBy: i)] {
22+
if utf8[utf8.index(utf8.startIndex, offsetBy: i)] != str.utf8[str.utf8.index(str.utf8.startIndex, offsetBy: i)] {
2323
return false
2424
}
2525
}
@@ -34,7 +34,7 @@
3434
}
3535
// FIXME: the complexity of this algorithm is O(n^2).
3636
for i in 0..<strCount {
37-
if utf8[utf8.location(utf8.startIndex, offsetBy: count-i-1)] != str.utf8[str.utf8.location(str.utf8.startIndex, offsetBy: strCount-i-1)] {
37+
if utf8[utf8.index(utf8.startIndex, offsetBy: count-i-1)] != str.utf8[str.utf8.index(str.utf8.startIndex, offsetBy: strCount-i-1)] {
3838
return false
3939
}
4040
}

Tests/Transmute/ModuleDependencyTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class ModuleDependencyTests: XCTestCase {
111111

112112
// precise order is not important, but it is important that the following are true
113113
let t6rd = t6.recursiveDeps
114-
XCTAssertEqual(t6rd.index(of: t3)!, t6rd.location(after: t6rd.index(of: t4)!))
114+
XCTAssertEqual(t6rd.index(of: t3)!, t6rd.index(after: t6rd.index(of: t4)!))
115115
XCTAssert(t6rd.index(of: t5)! < t6rd.index(of: t2)!)
116116
XCTAssert(t6rd.index(of: t5)! < t6rd.index(of: t1)!)
117117
XCTAssert(t6rd.index(of: t2)! < t6rd.index(of: t1)!)
@@ -142,7 +142,7 @@ class ModuleDependencyTests: XCTestCase {
142142

143143
// precise order is not important, but it is important that the following are true
144144
let t6rd = t6.recursiveDeps
145-
XCTAssertEqual(t6rd.index(of: t3)!, t6rd.location(after: t6rd.index(of: t4)!))
145+
XCTAssertEqual(t6rd.index(of: t3)!, t6rd.index(after: t6rd.index(of: t4)!))
146146
XCTAssert(t6rd.index(of: t5)! < t6rd.index(of: t2)!)
147147
XCTAssert(t6rd.index(of: t5)! < t6rd.index(of: t1)!)
148148
XCTAssert(t6rd.index(of: t2)! < t6rd.index(of: t1)!)

0 commit comments

Comments
 (0)