88
99import Foundation
1010
11- struct CleanJSONKeyedDecodingContainer < K : CodingKey > : KeyedDecodingContainerProtocol {
11+ struct CleanJSONKeyedDecodingContainer < K: CodingKey > : KeyedDecodingContainerProtocol {
1212
1313 typealias Key = K
1414
@@ -18,15 +18,15 @@ struct CleanJSONKeyedDecodingContainer<K : CodingKey>: KeyedDecodingContainerPro
1818 private let decoder : _CleanJSONDecoder
1919
2020 /// A reference to the container we're reading from.
21- private let container : [ String : Any ]
21+ private let container : [ String : Any ]
2222
2323 /// The path of coding keys taken to get to this point in decoding.
2424 private( set) public var codingPath : [ CodingKey ]
2525
2626 // MARK: - Initialization
2727
2828 /// Initializes `self` by referencing the given decoder and container.
29- init ( referencing decoder: _CleanJSONDecoder , wrapping container: [ String : Any ] ) {
29+ init ( referencing decoder: _CleanJSONDecoder , wrapping container: [ String : Any ] ) {
3030 self . decoder = decoder
3131 switch decoder. options. keyDecodingStrategy {
3232 case . useDefaultKeys:
@@ -416,7 +416,7 @@ struct CleanJSONKeyedDecodingContainer<K : CodingKey>: KeyedDecodingContainerPro
416416 }
417417
418418 @inline ( __always)
419- public func decode< T : Decodable > ( _ type: T . Type , forKey key: Key ) throws -> T {
419+ public func decode< T: Decodable > ( _ type: T . Type , forKey key: Key ) throws -> T {
420420 guard let entry = container [ key. stringValue] else {
421421 switch decoder. options. keyNotFoundDecodingStrategy {
422422 case . throw:
@@ -487,12 +487,12 @@ struct CleanJSONKeyedDecodingContainer<K : CodingKey>: KeyedDecodingContainerPro
487487 }
488488 }
489489
490- guard let dictionary = value as? [ String : Any ] else {
490+ guard let dictionary = value as? [ String : Any ] else {
491491 switch decoder. options. nestedContainerDecodingStrategy. typeMismatch {
492492 case . throw:
493493 throw DecodingError . _typeMismatch (
494494 at: self . codingPath,
495- expectation: [ String : Any ] . self,
495+ expectation: [ String : Any ] . self,
496496 reality: value)
497497 case . useEmptyContainer:
498498 return nestedContainer ( )
@@ -863,7 +863,7 @@ extension CleanJSONKeyedDecodingContainer {
863863 }
864864
865865 @inline ( __always)
866- func decodeIfPresent< T> ( _ type: T . Type , forKey key: K ) throws -> T ? where T : Decodable {
866+ func decodeIfPresent< T> ( _ type: T . Type , forKey key: K ) throws -> T ? where T: Decodable {
867867 guard contains ( key) , let entry = container [ key. stringValue] else { return nil }
868868
869869 decoder. codingPath. append ( key)
@@ -939,7 +939,7 @@ private extension CleanJSONDecoder.KeyDecodingStrategy {
939939 let trailingUnderscoreRange = stringKey. index ( after: lastNonUnderscore) ..< stringKey. endIndex
940940
941941 let components = stringKey [ keyRange] . split ( separator: " _ " )
942- let joinedString : String
942+ let joinedString : String
943943 if components. count == 1 {
944944 // No underscores in key, leave the word as is - maybe already camel cased
945945 joinedString = String ( stringKey [ keyRange] )
@@ -948,13 +948,13 @@ private extension CleanJSONDecoder.KeyDecodingStrategy {
948948 }
949949
950950 // Do a cheap isEmpty check before creating and appending potentially empty strings
951- let result : String
952- if ( leadingUnderscoreRange. isEmpty && trailingUnderscoreRange. isEmpty) {
951+ let result : String
952+ if leadingUnderscoreRange. isEmpty && trailingUnderscoreRange. isEmpty {
953953 result = joinedString
954- } else if ( !leadingUnderscoreRange. isEmpty && !trailingUnderscoreRange. isEmpty) {
954+ } else if !leadingUnderscoreRange. isEmpty && !trailingUnderscoreRange. isEmpty {
955955 // Both leading and trailing underscores
956956 result = String ( stringKey [ leadingUnderscoreRange] ) + joinedString + String( stringKey [ trailingUnderscoreRange] )
957- } else if ( !leadingUnderscoreRange. isEmpty) {
957+ } else if !leadingUnderscoreRange. isEmpty {
958958 // Just leading
959959 result = String ( stringKey [ leadingUnderscoreRange] ) + joinedString
960960 } else {
0 commit comments