File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -145,13 +145,11 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
145145
146146 @inline ( __always)
147147 func unwrap< T: Decodable > ( ) throws -> T {
148- let value = representation
149-
150148 typealias Primitive = DynamicCodable
151149
152150 switch T . self {
153151 // Return DynamicCodable as is if it is being decoded
154- case is DynamicCodable . Type : return unsafeBitCast ( value , to: T . self)
152+ case is DynamicCodable . Type : return unsafeBitCast ( representation , to: T . self)
155153 // Primitive Types fast-path
156154 case is Primitive . Float32 . Type : return unsafeBitCast ( try unwrapFloatingPoint ( ) as Primitive . Float32 , to: T . self)
157155 case is Primitive . Float64 . Type : return unsafeBitCast ( try unwrapFloatingPoint ( ) as Primitive . Float64 , to: T . self)
@@ -170,12 +168,17 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
170168 is Primitive . Nil . Type ,
171169 is Primitive . Bool . Type ,
172170 is Primitive . String . Type ,
173- is Primitive . Empty . Type : return try value . unwrap { throw createTypeMismatchError ( type : T . self ) }
171+ is Primitive . Empty . Type : return try unwrapPrimitive ( )
174172 // Decodable Types
175173 default : return try T ( from: self )
176174 }
177175 }
178176
177+ @inline ( __always)
178+ private func unwrapPrimitive< T> ( ) throws -> T {
179+ try representation. unwrap { throw createTypeMismatchError ( type: T . self) }
180+ }
181+
179182 @inline ( __always)
180183 private func unwrapFloatingPoint< T: BinaryFloatingPoint > ( ) throws -> T {
181184 @inline ( __always)
You can’t perform that action at this time.
0 commit comments