@@ -106,11 +106,9 @@ private struct JSONMap {
106106 let data : [ Int ]
107107
108108 /// 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!) )
114112 }
115113 }
116114}
@@ -188,7 +186,7 @@ private struct JSONScanner {
188186 }
189187
190188 @inline ( __always)
191- mutating func skipWhilespace ( ) {
189+ mutating func skipWhitespace ( ) {
192190 while hasData {
193191 switch ptr. pointee {
194192 case UInt8 ( ascii: " " ) , UInt8 ( ascii: " \t " ) , UInt8 ( ascii: " \n " ) , UInt8 ( ascii: " \r " ) :
@@ -291,15 +289,15 @@ private struct JSONScanner {
291289
292290 mutating func scanObject( ) throws {
293291 let handle = map. startCollection ( . object)
294- skipWhilespace ( )
292+ skipWhitespace ( )
295293 if !advance( if: " } " ) {
296294 while hasData {
297295 try scanString ( start: ptr)
298- skipWhilespace ( )
296+ skipWhitespace ( )
299297 try expect ( " : " )
300298 try scanValue ( )
301299 if advance ( if: " , " ) {
302- skipWhilespace ( )
300+ skipWhitespace ( )
303301 continue
304302 }
305303 break
@@ -311,12 +309,12 @@ private struct JSONScanner {
311309
312310 mutating func scanArray( ) throws {
313311 let handle = map. startCollection ( . array)
314- skipWhilespace ( )
312+ skipWhitespace ( )
315313 if !advance( if: " ] " ) {
316314 while hasData {
317315 try scanValue ( )
318316 if advance ( if: " , " ) {
319- skipWhilespace ( )
317+ skipWhitespace ( )
320318 continue
321319 }
322320 break
@@ -327,7 +325,7 @@ private struct JSONScanner {
327325 }
328326
329327 mutating func scanValue( ) throws {
330- skipWhilespace ( )
328+ skipWhitespace ( )
331329 let start = ptr
332330 switch try advance ( ) {
333331 case UInt8 ( ascii: " n " ) :
@@ -347,7 +345,7 @@ private struct JSONScanner {
347345 case let chr:
348346 throw JSONError . unexpectedCharacter ( chr, context: " value start " )
349347 }
350- skipWhilespace ( )
348+ skipWhitespace ( )
351349 }
352350
353351 static func scan( buffer: UnsafeBufferPointer < UInt8 > ) throws -> JSONMap {
@@ -689,11 +687,6 @@ extension JSONMapValue {
689687 func contains( key: String ) -> Bool {
690688 return find ( key) != nil
691689 }
692-
693- @inline ( __always)
694- subscript( _ key: String ) -> JSONMapValue ? {
695- return find ( key)
696- }
697690 }
698691
699692 @inline ( __always)
@@ -924,7 +917,7 @@ extension JSONDecoding.KeyedContainer: KeyedDecodingContainerProtocol {
924917
925918 @inline ( __always)
926919 func _getOrThrow( forKey key: Key ) throws -> JSONMapValue {
927- if let value = mapping [ key. stringValue] {
920+ if let value = mapping. find ( key. stringValue) {
928921 return value
929922 }
930923 throw DecodingError . keyNotFound (
0 commit comments