Skip to content

Commit 082336a

Browse files
committed
Merge pull request #161 from stephencelis/tidying
Use more succinct code and constructs (nfc)
2 parents 8cbdaef + 2927090 commit 082336a

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

Sources/ManifestParser/TOML.swift

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

214214
// Consume and cache the next character.
215215
lookahead = utf8[index]
216-
nextIndex = index.advancedBy(1)
216+
nextIndex = index.successor()
217217

218218
// Normalize line endings.
219219
if lookahead == "\r".utf8Constant && utf8[nextIndex!] == "\n".utf8Constant {
220-
nextIndex = nextIndex!.advancedBy(1)
220+
nextIndex = nextIndex!.successor()
221221
lookahead = "\n".utf8Constant
222222
}
223223

@@ -277,7 +277,7 @@ private struct Lexer {
277277
break
278278
}
279279
}
280-
return .StringLiteral(value: String(utf8[Range(start: startIndex.advancedBy(1), end: endIndex)]))
280+
return .StringLiteral(value: String(utf8[Range(start: startIndex.successor(), end: endIndex)]))
281281

282282
// Numeric literals.
283283
//

Sources/ManifestParser/fromTOML().swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extension PackageDescription.Target {
9595

9696
// Parse the dependencies.
9797
var dependencies: [PackageDescription.Target.Dependency] = []
98-
if case .Some(.Array(let array)) = table.items["dependencies"] {
98+
if case .Array(let array)? = table.items["dependencies"] {
9999
for item in array.items {
100100
dependencies.append(PackageDescription.Target.Dependency.fromTOML(item))
101101
}

Sources/Utility/StringExtensions.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ extension String {
4848

4949
loop: while true {
5050
switch cc.first {
51-
case .None:
51+
case nil:
5252
return nil
53-
case .Some("\n"), .Some("\r"), .Some(" "), .Some("\t"), .Some("\r\n"):
53+
case "\n"?, "\r"?, " "?, "\t"?, "\r\n"?:
5454
cc = cc.dropFirst()
5555
default:
5656
break loop
@@ -59,9 +59,9 @@ extension String {
5959

6060
loop: while true {
6161
switch cc.last {
62-
case .None:
62+
case nil:
6363
return nil
64-
case .Some("\n"), .Some("\r"), .Some(" "), .Some("\t"), .Some("\r\n"):
64+
case "\n"?, "\r"?, " "?, "\t"?, "\r\n"?:
6565
cc = cc.dropLast()
6666
default:
6767
break loop

Tests/Transmute/ModuleTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class ModuleTests: XCTestCase {
114114

115115
// precise order is not important, but it is important that the following are true
116116
let t6rd = t6.recursiveDeps
117-
XCTAssertEqual(t6rd.indexOf(t3)!, t6rd.indexOf(t4)!.advancedBy(1))
117+
XCTAssertEqual(t6rd.indexOf(t3)!, t6rd.indexOf(t4)!.successor())
118118
XCTAssert(t6rd.indexOf(t5)! < t6rd.indexOf(t2)!)
119119
XCTAssert(t6rd.indexOf(t5)! < t6rd.indexOf(t1)!)
120120
XCTAssert(t6rd.indexOf(t2)! < t6rd.indexOf(t1)!)
@@ -143,7 +143,7 @@ class ModuleTests: XCTestCase {
143143

144144
// precise order is not important, but it is important that the following are true
145145
let t6rd = t6.recursiveDeps
146-
XCTAssertEqual(t6rd.indexOf(t3)!, t6rd.indexOf(t4)!.advancedBy(1))
146+
XCTAssertEqual(t6rd.indexOf(t3)!, t6rd.indexOf(t4)!.successor())
147147
XCTAssert(t6rd.indexOf(t5)! < t6rd.indexOf(t2)!)
148148
XCTAssert(t6rd.indexOf(t5)! < t6rd.indexOf(t1)!)
149149
XCTAssert(t6rd.indexOf(t2)! < t6rd.indexOf(t1)!)

0 commit comments

Comments
 (0)