File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed
Sources/SwiftCompilerPluginMessageHandling/JSON Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -141,17 +141,15 @@ private struct JSONWriter {
141
141
var string = string
142
142
write ( ascii: " \" " )
143
143
string. withUTF8 { utf8 in
144
- var cursor = utf8. baseAddress!
145
- let end = utf8. baseAddress! + utf8. count
146
- var mark = cursor
147
- func flush( ) {
148
- if cursor > mark {
144
+ let start = utf8. baseAddress!
145
+ let end = start + utf8. count
146
+ var mark = start
147
+
148
+ for cursor in start..< end {
149
+ @inline ( __always) func flush( ) {
149
150
write ( utf8: UnsafeBufferPointer ( start: mark, count: cursor - mark) )
151
+ mark = cursor + 1
150
152
}
151
- cursor += 1
152
- mark = cursor
153
- }
154
- while cursor != end {
155
153
switch cursor. pointee {
156
154
case UInt8 ( ascii: " \" " ) :
157
155
flush ( )
@@ -186,13 +184,13 @@ private struct JSONWriter {
186
184
}
187
185
default :
188
186
// Accumulate this byte.
189
- cursor += 1
187
+ break
190
188
}
191
189
}
192
190
193
191
// Append accumulated bytes.
194
- if cursor > mark {
195
- write ( utf8: UnsafeBufferPointer ( start: mark, count: cursor - mark) )
192
+ if end > mark {
193
+ write ( utf8: UnsafeBufferPointer ( start: mark, count: end - mark) )
196
194
}
197
195
}
198
196
write ( ascii: " \" " )
You can’t perform that action at this time.
0 commit comments