@@ -106,11 +106,9 @@ private struct JSONMap {
106
106
let data : [ Int ]
107
107
108
108
/// Top-level value.
109
- func withValue< T> ( _ fn: ( JSONMapValue ) throws -> T ) rethrows -> T {
110
- try withExtendedLifetime ( data) {
111
- try data. withUnsafeBufferPointer { buf in
112
- try fn ( JSONMapValue ( data: buf. baseAddress!) )
113
- }
109
+ func withValue< T> ( _ body: ( JSONMapValue ) throws -> T ) rethrows -> T {
110
+ try data. withUnsafeBufferPointer { buf in
111
+ try body ( JSONMapValue ( data: buf. baseAddress!) )
114
112
}
115
113
}
116
114
}
@@ -188,7 +186,7 @@ private struct JSONScanner {
188
186
}
189
187
190
188
@inline ( __always)
191
- mutating func skipWhilespace ( ) {
189
+ mutating func skipWhitespace ( ) {
192
190
while hasData {
193
191
switch ptr. pointee {
194
192
case UInt8 ( ascii: " " ) , UInt8 ( ascii: " \t " ) , UInt8 ( ascii: " \n " ) , UInt8 ( ascii: " \r " ) :
@@ -291,15 +289,15 @@ private struct JSONScanner {
291
289
292
290
mutating func scanObject( ) throws {
293
291
let handle = map. startCollection ( . object)
294
- skipWhilespace ( )
292
+ skipWhitespace ( )
295
293
if !advance( if: " } " ) {
296
294
while hasData {
297
295
try scanString ( start: ptr)
298
- skipWhilespace ( )
296
+ skipWhitespace ( )
299
297
try expect ( " : " )
300
298
try scanValue ( )
301
299
if advance ( if: " , " ) {
302
- skipWhilespace ( )
300
+ skipWhitespace ( )
303
301
continue
304
302
}
305
303
break
@@ -311,12 +309,12 @@ private struct JSONScanner {
311
309
312
310
mutating func scanArray( ) throws {
313
311
let handle = map. startCollection ( . array)
314
- skipWhilespace ( )
312
+ skipWhitespace ( )
315
313
if !advance( if: " ] " ) {
316
314
while hasData {
317
315
try scanValue ( )
318
316
if advance ( if: " , " ) {
319
- skipWhilespace ( )
317
+ skipWhitespace ( )
320
318
continue
321
319
}
322
320
break
@@ -327,7 +325,7 @@ private struct JSONScanner {
327
325
}
328
326
329
327
mutating func scanValue( ) throws {
330
- skipWhilespace ( )
328
+ skipWhitespace ( )
331
329
let start = ptr
332
330
switch try advance ( ) {
333
331
case UInt8 ( ascii: " n " ) :
@@ -347,7 +345,7 @@ private struct JSONScanner {
347
345
case let chr:
348
346
throw JSONError . unexpectedCharacter ( chr, context: " value start " )
349
347
}
350
- skipWhilespace ( )
348
+ skipWhitespace ( )
351
349
}
352
350
353
351
static func scan( buffer: UnsafeBufferPointer < UInt8 > ) throws -> JSONMap {
@@ -689,11 +687,6 @@ extension JSONMapValue {
689
687
func contains( key: String ) -> Bool {
690
688
return find ( key) != nil
691
689
}
692
-
693
- @inline ( __always)
694
- subscript( _ key: String ) -> JSONMapValue ? {
695
- return find ( key)
696
- }
697
690
}
698
691
699
692
@inline ( __always)
@@ -924,7 +917,7 @@ extension JSONDecoding.KeyedContainer: KeyedDecodingContainerProtocol {
924
917
925
918
@inline ( __always)
926
919
func _getOrThrow( forKey key: Key ) throws -> JSONMapValue {
927
- if let value = mapping [ key. stringValue] {
920
+ if let value = mapping. find ( key. stringValue) {
928
921
return value
929
922
}
930
923
throw DecodingError . keyNotFound (
0 commit comments