@@ -15,16 +15,16 @@ let quote = "\"".utf16.first!
15
15
16
16
func parseQuotedField( _ remainder: inout Substring ) throws -> Substring ? {
17
17
var result : Substring = " " // we accumulate the result
18
-
18
+
19
19
while !remainder. isEmpty {
20
20
guard let nextQuoteIndex = remainder. index ( of: " \" " ) else {
21
21
throw ParseError ( message: " Expected a closing \" " )
22
22
}
23
-
23
+
24
24
// Append until the next quote
25
25
result += remainder. prefix ( upTo: nextQuoteIndex)
26
26
remainder. remove ( upToAndIncluding: nextQuoteIndex)
27
-
27
+
28
28
if let peek = remainder. utf16. first {
29
29
switch peek {
30
30
case quote: // two quotes after each other is an escaped quote
@@ -41,7 +41,7 @@ func parseQuotedField(_ remainder: inout Substring) throws -> Substring? {
41
41
return result
42
42
}
43
43
}
44
-
44
+
45
45
throw ParseError ( message: " Expected a closing quote " )
46
46
}
47
47
@@ -80,7 +80,7 @@ extension Substring {
80
80
mutating func remove( upTo index: Index ) {
81
81
self = suffix ( from: index)
82
82
}
83
-
83
+
84
84
mutating func remove( upToAndIncluding index: Index ) {
85
85
self = suffix ( from: self . index ( after: index) )
86
86
}
@@ -133,10 +133,10 @@ public func run_CSVParsing(_ N: Int) {
133
133
134
134
for _ in 0 ..< N {
135
135
var remainder = contents [ ... ]
136
-
136
+
137
137
var result : Int = 0
138
138
var x : ( ) = ( )
139
-
139
+
140
140
while !remainder. isEmpty {
141
141
blackHole ( try ? parseLine ( & remainder, result: & x, processField: { state, _, field in
142
142
( )
0 commit comments